-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Hibernate how to operate dynamic table ??
PostPosted: Mon Apr 28, 2008 8:37 am 
Newbie

Joined: Fri Apr 11, 2008 3:58 am
Posts: 2
Hi , everybody

Hibernate how to operate dynamic table ?

I know a common method: use SQLQuery.

For example:
Code:
      String sql = "select  title, subject , mailaddr   from  test_20080420 ";
      List res_list = session.createSQLQuery(sql).list();
     .........
   


Now , I want to use class 'EmailData' to encapsulate the information of table 'test_20080420' , how can i do it ? My hibernate version is 3.0 .

The Object pojo EmailData class:
Code:
    public class EmailData{

        private String title;
        private String subject;
        private String mailaddr;

        public EmailData(){}
         
        public EmailData(String title,String subject,String mailaddr){
             this.title = title;
             this.subject = subject;
             this.mailaddr = mailaddr;
       }

      /*  the setter / getter method */
      ................................

   }
   
 


Is there other better methods to operate dynamic table by hibernate ??


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 07, 2008 3:00 am 
Newbie

Joined: Sun May 06, 2007 5:57 am
Posts: 10
You can use addEntity:
Code:
List res_list = session.createSQLQuery(sql).addEntity(EmailData.class).list();


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.