-->
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: place for annotations instructions in interface or class
PostPosted: Fri Jan 25, 2008 10:22 pm 
Beginner
Beginner

Joined: Mon Jan 07, 2008 4:13 am
Posts: 22
hi!,

i`m a beginner in hibernate, i have question about annotations informations place, if i use interface and one inherited class.

Code:

@Entity
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="value_type",
   discriminatorType=DiscriminatorType.STRING
)
@Table(name="house_property_value")
@javax.persistence.SequenceGenerator(
   name="seq_house_property_value",
   sequenceName="s_house_property_value",
   allocationSize=1
)
public interface HousePropertyValue extends Serializable {
   @Id
   @GeneratedValue(strategy = GenerationType.SEQUENCE, generator="seq_house_property_value")
   public Long getId();
   public void setId(Long id);
   @Column(name="value_key", nullable = false)
   public String getValueKey();
   public void setValueKey(String valueKey);
   @ManyToOne (fetch = FetchType.LAZY, cascade = CascadeType.ALL)
   @JoinColumn(name = "fk_house_id", referencedColumnName = "id", nullable = false)
   public House getHouse();
   public void setHouse(House house);
   public Object getValue();
   public void setValue(Object value);
}



if i have this interface, it is neccesary to have all annotations instructions here, or it is possible to remove these instruction to inherited class ? Or is there any rules for position of these instructions ?

inherited class:

Code:

@Entity
@DiscriminatorValue("DATE")
@javax.persistence.SequenceGenerator(
   name="seq_house_property_value",
   sequenceName="s_house_property_value",
   allocationSize=1
)
public class HousePropertyDateValue implements HousePropertyValue {

   @Id
   @GeneratedValue(strategy = GenerationType.SEQUENCE, generator="seq_house_property_value")
   private Long id;
   private House house;
   private String valueKey;
   @Column(name="value_date", nullable=false)
   private Date value = new Date();
   public HousePropertyDateValue() {}
   public HousePropertyDateValue(Date value) {    this.value = value;    }
   public Long getId() {       return id;    }
   public void setId(Long id) {         this.id = id;    }
   public String getValueKey() {         return valueKey;    }
   public void setValueKey(String valueKey) {   this.valueKey = valueKey;    }
   public House getHouse() {        return house;    }
   public void setHouse(House house) {        this.house = house;    }
   public Date getValue()    {        return value;    }
   public void setValue( Date value )    {        this.value = value;    }
   public void setValue( Object value )    {        this.value = (Date) value;    }
}



thanks!

Ivan


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 31, 2008 12:42 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Annotation the interface is not officially supported, I don't think it works.

_________________
Emmanuel


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.