English 中文(简体)
如何以保密标准执行 反对与内心结合的选定询问
原标题:How to implement with hibernate criteria Object the select query with inner join

I m new with Hibernate and Criteria Query. So I have implemented the query in HQL:

select A.mobilephone
    B.userNick
    C.creditCard
from mobile_table A
inner join user_table B
    on A.codmobile=B.codmobile
inner join Credit C 
    on A.mobileCredit= C.mobileCredit

我如何以“自愿标准目标”来实施?

最佳回答

你的榜样只是一个本土的地理结构,而不是一个地方。 任何方面,均可使用。 2. 拟订预期标准标的的标语:

例如,如果是:

select
    TableA.columnA ,TableB.columnB ,TableC.columnC
from TableA 
inner join TableB on TableA.tableB_id=TableB.id
inner join TableC on TableA.tableC_id=TableC.id
where TableA.columnAA="AAA"
and TableB.columnBB="BBB"
and TableC.columnCC="CCC"

然后,标准目标将是:

List<Object[]>resultList= (List<Object[]>)session.createCriteria(TableA.class, "aliasOfTableA") 
                .add(Restrictions.eq("aliasOfTableA.columnAA", "AAA"))  
                .createCriteria("aliasOfTableA.tableBId" , "aliasOfTableB")
                .add(Restrictions.eq("aliasOfTableB.columnBB", "BBB"))
                .createCriteria("aliasOfTableA.tableCId" , "aliasOfTableC")
                .add(Restrictions.eq("aliasOfTableC.columnCC", "CCC"))
                .setProjection( Projections.projectionList()
                        .add( Projections.property("aliasOfTableA.columnA") )
                        .add( Projections.property("aliasOfTableB.columnB"))
                        .add( Projections.property("aliasOfTableC.columnC") )
                ).list();

for (Object[] obj : resultList) {
        System.out.println(obj[0]); //print the value from TableA.columnA
        System.out.println(obj[1]); //print the value from TableB.columnB
        System.out.println(obj[2]); //print the value from TableC.columnC
}   

请注意,<代码>Criteria中的所有参数均使用被测绘的 Java实体的财产名称和类别名称。

问题回答

你们是否确保了总部? 看像本地人,我。

为了使用标准,必须绘制地图并相互联系起来(因为标准只允许联系途径)。 我认为,如果你详细介绍你的地图,你会获得更多帮助。





相关问题
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 ...

热门标签