-->
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.  [ 3 posts ] 
Author Message
 Post subject: Domain code generated by Hibernate Tools
PostPosted: Tue Mar 13, 2007 9:52 am 
Beginner
Beginner

Joined: Tue Mar 13, 2007 9:46 am
Posts: 20
I have reverse engineered my database and generated domain code with Hibernate Tools. For each table (e.g. tabA), I get a file tabA.java and a file tabAId.java.

How are these supposed to be used? I want to write code like this:

tabA mtab = new tabA();
mtab.setPersonName("Bobby");
session.save(mtab);

However, the table fields are not available in the tabA.java-file, just in the tabAId.java-file. The tabA.java-file just contains the field:

private tabAId id;

with getters and setters.

I have tried to find some documentation on this matter, without success. Anybody how can help explain how these two files relate and how they are supposed to be used?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 13, 2007 10:31 am 
Expert
Expert

Joined: Tue Jul 11, 2006 10:21 am
Posts: 457
Location: Columbus, Ohio
Sounds to me like you do not have primary keys on your tables. Since there are no primary keys, the reverse engineering tools attempt to use a natural key. Since there is no natural key defined, it will assume that all columns make up a composite key. Easy fix: put primary keys on your tables or mark them as such in the reverse engineering file.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 14, 2007 3:41 am 
Beginner
Beginner

Joined: Tue Mar 13, 2007 9:46 am
Posts: 20
You are absolutely correct! That was the issue - thx!


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