-->
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.  [ 1 post ] 
Author Message
 Post subject: Problem with @ANY and Foreign-Key
PostPosted: Wed Aug 24, 2011 9:59 am 
Newbie

Joined: Wed Aug 24, 2011 9:47 am
Posts: 1
Hi,

I have the entities "User" and "Customer":
Code:
@Entity
@Table(name = "USR_USER")
public class User extends PersistentObject {

   [...]

   @Any(metaColumn = @Column(name = "USR_OWNERTYPE"))
   @AnyMetaDef(idType = "long", metaType = "string", metaValues = {
         @MetaValue(targetEntity = Customer.class, value = "CST"),
         @MetaValue(targetEntity = Client.class, value = "CLT") })
   @JoinColumn(name = "USR_OWNERID")
   private PersistentObject owner;
}

@Entity
@Table(name = "CST_CUSTOMER")
public class Customer extends PersistentObject {

   @Id
   @GeneratedValue
   @Column(name="CST_ID")
   private long id;

   [...]

   // @OneToMany(mappedBy = "owner")
   private transient Set<User> users;
}

Running this (using spring), I got the following exception:

Code:
Caused by: org.hibernate.MappingException: Foreign key (FK35B91BB65D577CEF:USR_USER [USR_OWNERTYPE,USR_OWNERID])) must have same number of columns as the referenced primary key (CST_CUSTOMER [CST_ID])

I do not understand this, because I mapped the class "Customer" in @AnyMetaDef (in "User") to the constant "CST".

What am I doing wrong?

Thanks in advance for any help
Thomas


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.