-->
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.  [ 6 posts ] 
Author Message
 Post subject: page 336
PostPosted: Sat Jan 06, 2007 5:40 pm 
Beginner
Beginner

Joined: Thu Nov 30, 2006 3:00 pm
Posts: 20
The text from the figure 8.1 says "A composite foreign key references a composite primary key." souldn't it be "... references a composite natural key."?

regards.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 06, 2007 6:08 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
It's indeed a wrong caption, but it should be "A composite foreign key references a composite unique key". Added to errata.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 18, 2008 4:13 pm 
Newbie

Joined: Thu Feb 14, 2008 10:43 pm
Posts: 8
christian wrote:
It's indeed a wrong caption, but it should be "A composite foreign key references a composite unique key". Added to errata.


The solution proposed on page 336 can be implemented with annotation ?

All my search on internet has failed.
It seem that not exist a "A composite foreign key references a composite unique key" example with annotation


Top
 Profile  
 
 Post subject: Page 336
PostPosted: Thu Mar 20, 2008 10:41 am 
Newbie

Joined: Thu Mar 20, 2008 10:39 am
Posts: 4
I am in desperate need of a JPA solution for the XML provided in the page 336. Any help!


Top
 Profile  
 
 Post subject: using JPA annotations
PostPosted: Fri Mar 28, 2008 4:08 pm 
Newbie

Joined: Thu Mar 27, 2008 10:50 am
Posts: 13
Item...
Code:
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;

@Entity
public class Item {
   @Id
   private long item_id;

   private double price;
   
   @ManyToOne
   @JoinColumns({
      @JoinColumn(name="seller_firstName", referencedColumnName="firstName", updatable=false),
      @JoinColumn(name="seller_lastName", referencedColumnName="lastName", updatable=false),
      @JoinColumn(name="seller_birthday", referencedColumnName="birthday", updatable=false)
   })
   private User seller;
}


User...
Code:
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

@Entity
@Table(name="Users", uniqueConstraints = {@UniqueConstraint(columnNames = {"firstName", "lastName", "birthday"})})
public class User {
   @Id
   private long user_id;
   
   private String firstName;
   private String lastName;
   private Date birthday;
   
   private String username;
   
   @OneToMany(mappedBy="seller")
   private Set<Item> itemsForAuction = new HashSet<Item>();
}


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 28, 2008 5:27 pm 
Newbie

Joined: Thu Mar 20, 2008 10:39 am
Posts: 4
Thanks!


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