-->
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: Hibernate Mapping
PostPosted: Wed Jan 09, 2008 3:38 pm 
Newbie

Joined: Wed Jan 09, 2008 3:25 pm
Posts: 1
Hi,

I am new Hibernate and i am trying to write annotated class. I have two domain objects.
(1) HandsetDeliveryMethod
(2) DeliveryMethod

The DeliveryMethod class :

Code:
@Entity
@Table(name = "DELIVERY_METHODS")
public class DeliveryMethod {
   
   private Integer id;
   private String name;
   private String description;
   
   
   private Set<HandsetDeliveryMethod> handsetDeliveryMethods;
   
   
   public Set<HandsetDeliveryMethod> getHandsetDeliveryMethods() {
      return handsetDeliveryMethods;
   }
   
   public void setHandsetDeliveryMethods(
         Set<HandsetDeliveryMethod> handsetDeliveryMethods) {
      this.handsetDeliveryMethods = handsetDeliveryMethods;
   }
   
   
   
   @Id
   @GeneratedValue(strategy=GenerationType.AUTO)
   public Integer getId() {
      return id;
   }
   
   
   public void setId(Integer id) {
      this.id = id;
   }
   
   
   @Column(name = "delivery_method_name")
   public String getName() {
      return name;
   }
   
   
   public void setName(String name) {
      this.name = name;
   }
   
   
   @Column(name = "description")
   public String getDescription() {
      return description;
   }
   
   
   public void setDescription(String description) {
      this.description = description;
   }
}



And the HandsetDeliveryMethod Class :

Code:
@Entity
@Table(name = "HANDSET_DELIVERY_METHODS")
public class HandsetDeliveryMethod {
   private Integer id;
   private DeliveryMethod deliveryMethod;
   private Integer priority;
   
   @Column(name = "priority")
   public Integer getPriority() {
      return priority;
   }
   
   public void setPriority(Integer priority) {
      this.priority = priority;
   }
   
   
   public DeliveryMethod getDeliveryMethod() {
      return deliveryMethod;
   }
   
   
   public void setDeliveryMethod(DeliveryMethod deliveryMethod) {
      this.deliveryMethod = deliveryMethod;
   }
   
   
   
   @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
   public Integer getId() {
      return id;
   }
   public void setId(Integer id) {
      this.id = id;
   }
}



Here I have done the simple attributes mapping But I want to establish a relationship between the deliveryMethod inside "HandsetDeliveryMethod" and "handsetDeliveryMethods" in "DeliveryMethod".

Any ideas?

Thanks in Advance..


Top
 Profile  
 
 Post subject: Re: Hibernate Mapping
PostPosted: Wed Jan 09, 2008 3:45 pm 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
what is the database like for the relation?


Farzad-


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.