-->
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.  [ 2 posts ] 
Author Message
 Post subject: The id of entity isn't id of the table
PostPosted: Thu Nov 19, 2009 6:43 am 
Newbie

Joined: Fri Apr 04, 2008 6:55 am
Posts: 3
Location: Belgium
Hello,

I would like to have your advice about something.

First, details on my environment : I use Hibernate 3.2.6.ga and ehcache 1.4.1.

I have a class with a generated id. But my application uses a unique property to search the entities and I would like to use ehcache according this unique property. So, the solution I've found is to set the Id annotation on my property.

Code:
@Entity
@Table(....)
public class EntityA {
     @Generated(GenerationTime.INSERT)
     @Column(unique=true)
     private Integer id;
     
     @Id
     private String uniqueProperty;

     ...
}


There's a difference between the database table and the entity.


So, my question : according to you, could it become a problem ?



Thank you.


Top
 Profile  
 
 Post subject: Re: The id of entity isn't id of the table
PostPosted: Thu Nov 19, 2009 7:34 am 
Senior
Senior

Joined: Mon Feb 25, 2008 1:48 am
Posts: 191
Location: India
What is your table structure?

I don't see a problem with your approach. Use the "name" attribute in column annotation to map the table column to the actual property in your entity and you should be good to go.

_________________
Sukirtha


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