Hibernate: How to force hibernate to define types for collections?
I am completely lost with the hibernation problem and hope you can help me =)!
Here's my problem:
I have a database with two tables, an address book and a contact. The relationship between them in my scenario is 1: n.
Now Hibernate generates the following code for me after reverse engineering in the "AbstractAddressbook" class:
private Set contacts = new HashSet(0);
But instead, I need the following:
private Set<Contact> contacts = new HashSet<Contact>(0);
How can I do this, where do I need to configure it for reverse engineering?
source to share
When you are working with MyEclipse, just add the HibernateTemplate that comes with MyEclipse
I suggest you follow this tutorial:
http://www.myeclipseide.com/documentation/quickstarts/hibernate/
source to share
Thanks for the clarification (I've cleaned up the trash here). I cannot say that I have any experience with Hibernate reverse engine. I would recommend using the Eclipse JPA tools (eclipse.org) and "generate entities" from a new JPA project using a simple JDBC connection. (There are many tutorials out there). It does a good job of mapping the database, and it does a pretty good job of inferring the correct types (you might need to change the set to a list or some such thing). I ran this 4 days ago against a moderately complex database and it worked great.
Unless you have a weird requirement (like it should be in a pure Hibernate XML config or whatever), JPA tools usually do well and they are free. (Note: JBoss tools, Eclipse plugin, must also have Hibernate tools and can generate xml mappings).
source to share