-->
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: What is the annotations equivalent for <natural-id>?
PostPosted: Mon Jan 23, 2006 10:32 pm 
Newbie

Joined: Wed Nov 16, 2005 11:52 am
Posts: 6
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.1.1, Hibernate Annotations3.1beta8

Hi,

I am switching from hbm.xml to hiberate annotations3.1beta8

How to I express <natural-id> in hibernate annotations?

Is there any documentation for switching from hibernate mapping files to annotations?

thank you,

Rishi


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 24, 2006 1:49 am 
Newbie

Joined: Thu Dec 22, 2005 4:09 am
Posts: 8
May be something like this?

Code:
@Table(uniqueConstraints = {@UniqueConstraint(columnNames = {"laboratory_id", "name"})})


Here is full code.

Code:
@Entity
@Table(uniqueConstraints = {@UniqueConstraint(columnNames = {"laboratory_id", "name"})})
@SequenceGenerator(name = "SEQ_INSTRUMENT", sequenceName = "SEQ_INSTRUMENT")
public class Instrument extends AbstractModelBean {
   @Override
   public String toString() {
      return BeanUtils2.toString(this, "id", "name");
   }
   ////////////////////////////////////////////////////////////////////////////
   //
   // Id
   //
   ////////////////////////////////////////////////////////////////////////////
   private Long m_id;
   @Id(generate = GeneratorType.SEQUENCE, generator = "SEQ_INSTRUMENT")
   public Long getId() {
      return m_id;
   }
   public void setId(Long id) {
      m_id = id;
   }
   ////////////////////////////////////////////////////////////////////////////
   //
   // name
   //
   ////////////////////////////////////////////////////////////////////////////
   private String m_name;
   @Column(length = 120)
   @NotNull
   public String getName() {
      return m_name;
   }
   public void setName(String name) {
      m_name = name;
   }
   ////////////////////////////////////////////////////////////////////////////
   //
   // laboratory
   //
   ////////////////////////////////////////////////////////////////////////////
   private Laboratory m_laboratory;
   @ManyToOne(optional = false)
   public Laboratory getLaboratory() {
      return m_laboratory;
   }
   public void setLaboratory(Laboratory laboratory) {
      m_laboratory = laboratory;
   }
}


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 25, 2006 2:32 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
natural id does not exist in annotation yet

_________________
Emmanuel


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.