-->
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: Generated value as mapping property for JoinColumn
PostPosted: Fri Oct 17, 2014 5:09 am 
Newbie

Joined: Fri Oct 17, 2014 4:38 am
Posts: 1
Hi everybody,

I have the following issue: all tables in my database have the technical fields like createDate, idCreateUser, changeDate, idChangeUser. These fields are managed by triggers (no way to change it). I have the following parent in all entities from this reason:

Code:
@MappedSuperclass
public abstract class AbstractEntity {

        @Temporal(TemporalType.TIMESTAMP)
   @Column(name = "CREATE_DATE", updatable = false, insertable = false)
   @Generated(GenerationTime.INSERT)
   private Date createDate;

   @ManyToOne(fetch = FetchType.LAZY)
   @JoinColumn(name = "ID_CREATE_USER", updatable = false, insertable = false)
   @Generated(GenerationTime.INSERT)
   private UserEntity createUser;

   @Temporal(TemporalType.TIMESTAMP)
   @Column(name = "CHANGE_DATE", insertable = false, updatable = false)
   @Generated(GenerationTime.ALWAYS)
   private Date changeDate;

   @ManyToOne(fetch = FetchType.LAZY)
   @JoinColumn(name = "ID_CHANGE_USER", updatable = false, insertable = false)
   @Generated(GenerationTime.ALWAYS)
   private UserEntity changeUser;
...
}


I've had no troubles with this structure till migration from Hibernate 3.6.1 to Hibernate 4.3.6. It seems that mapping (@JoinColumn) doesn't work for generated values anymore (although it did). The application throws the common exception
Code:
org.hibernate.MappingException: Unknown entity:...

As I did some debugging the Hibernate tries to initialize the first entity (I don't know in which order it loads the entities - I use Hibernate with Spring and use the packagesToScan feature) and it fails at creating of its own representation because the UserEntity is not known to him.

Does anybody have the similar experience or ideas what to do here?

Thank you in advance!


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.