Beginner hibernate, I spent a pair of two tables, I have encountered a small problem that cannot be displayed. I have not found a document around. Now I have resolved, the result is as follows: The call program is as follows: Import java.util .Iterator; public class Client {public Client () {} public static void main (String [] args) {blogMain blogMain = new blogMain (); try {blogMain.exportTables (); blogMain.configure (); Blog blog = blogMain .CreateBlog ("Test"); Blogmain.createBlogitem (Blog, "Test1", "String1"); Blogmain.createBlogItem (Blog, "Test2", "String2"); Blogmain.createBlogItem (Blog, "Test3", "string3 "); List list = blogmain.listblogsandRecentItems (); itrator it = list.ITERATOR (); while (it.hasnext ()) {object [] row = (object []) it.next (); blog bluetest = BLOW [0]; BlogItem BlogItem = (BlogItem) Row [1]; System.Out.println (Blogtest.getID () ":" BLOGITEM.GETTEXT ()) }}} Catch (HibernateException ex) {throw new runtimeException ("Exception Building SessionFactory: ex.getMessage (), EX);}}} where blogmain.listblogsandrecentItems (); Public List ListBlogsandRecentItems () throws hibernateException {
Session session = _SESSIONS.OPENSESSION (); transaction tx = null; list result = null; try {tx = session.begintransaction (); query = session.createQuery ("from blom blog as blog" inner join blog.Items as BLOGITEM " " Where blogItem.datetime>: mindate ");
Calendar Cal = Calendar.GetInstance (); Cal. Roll (Calendar.mont, False); Q.Setcalendar ("Mindate", CAL); Result = q.list (); tx.commit ();} catch (HibernateException HE ) {IF (tx! = Null) tx.rollback (); throw he;} finally {session.close ();} Return Result;} The result of the query display is as follows: 1: 2: String1
1: 3: String2
1: 4: String3