-->
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.  [ 4 posts ] 
Author Message
 Post subject: Questions about generated files
PostPosted: Thu Mar 15, 2007 11:58 am 
Beginner
Beginner

Joined: Tue Mar 13, 2007 9:46 am
Posts: 20
I am using Hibernate tools and have some questions on the files generated:

1. When a table consists of a PK with e.g. two fields, a separate tableId.java file is generated when choosing Domain Code. I assume to use this I would need to:

tableId myId = new tableId(valA, valB)
table myTable = new table(myId).
.
.
.
myTable.save()

Is this a correct assumption?

2. How am I supposed to use the generated DAO-file? Any examples on when this is useful? I have written my own DAO and it does not include any of the generated DAO-functions, so I am not sure of the use her...

Regards,
Stein


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 15, 2007 12:04 pm 
Expert
Expert

Joined: Tue Jul 11, 2006 10:21 am
Posts: 457
Location: Columbus, Ohio
1) Yeah, that'll work if your keys are assigned manually (through code) and not generated.

2) If you already have DAO's, then why generate new ones?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 15, 2007 1:13 pm 
Beginner
Beginner

Joined: Tue Mar 13, 2007 9:46 am
Posts: 20
1) Thx!

2) My concern was not the DAO, but that my DAO did not have any of the generated functions, which made me suspect I had done something wrong in my DAO (misunderstanding of the whole concept...)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 15, 2007 1:22 pm 
Expert
Expert

Joined: Tue Jul 11, 2006 10:21 am
Posts: 457
Location: Columbus, Ohio
You probably got a bit confused with the state-oriented methods in the generated DAO, yes? It used to be relatively unusual to write domain-object state-oriented methods (persist, remove...) in DAOs. The Hibernate team was involved in fashioning JSR220 (JPA), which moved from a command-oriented architecture (insert, delete, update) to a state-oriented architecture (persist, remove, attach). That'll throw you off if you are used to the old methodology of DAO's.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.