English 中文(简体)
• 如何在普通班级中取得总部产出
原标题:How to get HQL output in a common class

我拥有多个班级的共同总部。

Query query = session.createQuery("select id, name from " + hibernateClass.getClass().getName());

<代码>query.list(); Return a List<Object[]>。 现在,查询结果的结构相同,即:Long idString name/code>。 因此,可以将这一内容归入一个类别,这样,当我打电话query.list()时,所有内容都并入一个清单,我不必再制作一个新的。 清单反对并填满。

最佳回答

有一些可能产生类似结果(小册子假定你希望有一个<条码>List<NewClass>,其结果是,新地图集才有财产复制和名称):

(1) 您从“+hibernateClass.getClass ()上选取新的地图册(同上,名称)

2) 您为新地图集创建了新的地图册,用于同一数据库表,但仅具有地契和名称,然后由“+新目录”查询。

3) You just do createQuery("from " + hibernateClass.getClass()) and you don t case about the superfluous values which where loaded. The extra amount of time for loading all columns compared to loading only the necessary columns is insignificant. If you prefer, you can nevertheless create a class or interface NewClass and for HibernateClass extends/implements NewClass.

Me personally I prefer 3), but that s up to your taste.

问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签