Because the primary key of each table is set at the beginning of the project design, but the foreign key cannot be set because of the project requirements, so there is no foreign key, when you use criteria to create a searcher
Failed. You cannot create a table by using multi-table join. An error is prompted as follows:
Criteria ir_a = This. getsession (). createcriteria (annualverificationfile. Class );
Ir_a.createalias ("housebaseinfo", "housebaseinfo ");
Here, the first housebaseinfo is estimated to be a foreign key factor. It is not generated in my ing file, and I don't know whether to manually modify the class ing relationship. Finally, I came up with another method.
Create a view of the associated table in the database, and then create a filter to retrieve the view.
The method is as follows:
Code
Criteria ir_vid = This . Getsession (). createcriteria (viewannualverificationfile. Class );
Ir_vid.setfirstresult (BI );
Ir_vid.setmaxresults (Limit );
If (Vannu. getdeliverycodename (). intvalue () ! = 0 )
Ir_vid.add (expression. eq ( " Id. deliverycodename " , Vannu. getdeliverycodename ()));
If (Vannu. getyearreportmaturity (). intvalue () ! = 0 )
Ir_vid.add (expression. eq ( " Id. yearreportmaturity " , Vannu. getyearreportmaturity ()));
If ( ! Vannu. getwarehouseno (). Equals ( "" ))
Ir_vid.add (expression. eq ( " Id. warehouseno " , Vannu. getwarehouseno ()));
If (Vannu. getfileclassify (). intvalue () ! = 0 )
Ir_vid.add (expression. eq ( " Id. fileclassify " , Vannu. getfileclassify ()));
List page_query = Ir_vid.list ();
// List page_query = This. gethibernatetemplate (). Find (querystring );
System. Out. println ( " Filter count: " + Page_query.size ());
If (Page_query.size () > 0 )
{
/** * *********************** Test for query result! OK ~~ : O
System. Out. println ("queied! ");
Java. util. iterator = page_query.iterator ();
While (iterator. hasnext ()){
Viewannualverificationfile ur = (viewannualverificationfile) iterator. Next ();
System. Out. println (Ur. GETID (). getwarehouseno () +
"\ T" + ur. GETID (). getfilename () +
"/" + Ur. GETID (). getfileclassify ());
}*/
Return Page_query;
}
Return Null ;