[jboss-user] [JBoss Seam] - HibernateEntityHome vs EntityHome

baz do-not-reply at jboss.com
Thu Feb 8 03:00:14 EST 2007


Hello,
Are there any difference between these two?
For example:
I have generated, with seam-gen, a short app containing one Entityclass called person..
Here is the generated code for the Home object:
@Name("personHome")
  | public class PersonHome extends EntityHome<Person>{
  |     @RequestParameter 
  |     Long personId;
  |     
  |     @Override
  |     public Object getId()    { 
  |         if (personId==null)       {
  |             return super.getId();
  |         }       else       {
  |             return personId;
  |         }
  |     }
  |     
  |     @Override @Begin
  |     public void create() {
  |         super.create();
  |     }
  |  }
Now i wanted to use HibernateEntityHome. The generated files were included in a working app with a hibernatesession. Then i modified the sources to match the new environment. The only intended change to the above file was to change EntityHome to HibernateEntityHome. 

But this results in an exception. (Session is null)
After an non intended change the class read like so:
@Name("personHome")
  | public class PersonHome extends HibernateEntityHome<Person>{
  |     @RequestParameter 
  |     Long personId;
  | 
  |     @In(create = true) private Session bazDatabase;
  |     @Override
  |     public Session getSession(){return bazDatabase;	}
  | 
  |     @Override
  |     public Object getId()    { 
  |         if (personId==null)       {
  |             return super.getId();
  |         }       else       {
  |             return personId;
  |         }
  |     }
  |     
  |     @Override @Begin
  |     public void create() {
  |         super.create();
  |     }
  |  }

1. Why is the entity manager implicit and the hibernatesession is not?
2. Why must i specify create="true"? I have set auto-creat="true" on the database
3. Is it possible to make the session implicit?
4. how?

Ciao Carsten

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4012885#4012885

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4012885



More information about the jboss-user mailing list