I've found that the problem is determining the primary key of my CatsDogs 
class.  I want my combined primary key to be the primary key of Cats and the 
primary key of Dogs.  I changed my code to:


  | @ManyToOne(optional=false)
  | @PrimaryKeyJoinColumn(name="cats_id",referencedColumnName="id")
  | public Cats getCats()
  | {
  |   return cats;
  | }
  | 
  | @ManyToOne(optional=false)
  | @PrimaryKeyJoinColumn(name="dogs_id",referencedColumnName="id")
  | public Dogs getDogs()
  | {
  |   return dogs;
  | }
  | 

However then JBoss complains that there is no primary key for this class.  If I 
add

@Id tags to the above methods, I get the same error posted above.

So, apparently the only solution is to add an additional ID field for the 
CatsDogs class that would be the primary key. It would then look like:


  | @Id
  | public int getId()
  | {
  |    return id;
  | }
  | ...
  | @ManyToOne(optional=false)
  | @PrimaryKeyJoinColumn(name="cats_id",referencedColumnName="id")
  | public Cats getCats()
  | {
  |   return cats;
  | }
  | ...
  | @ManyToOne(optional=false)
  | @PrimaryKeyJoinColumn(name="dogs_id",referencedColumnName="id")
  | public Dogs getDogs()
  | {
  |   return dogs;
  | }
  | 
  | 
  
This would take my database out of Third Normal Form and I don't want to do 
that.

Does anyone know how to fix this problem???

Thanks!

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

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


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to