-->
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: @OneToMany primary key part of foreign key
PostPosted: Sun Nov 20, 2011 5:21 pm 
Newbie

Joined: Thu Jul 28, 2011 2:54 pm
Posts: 12
I'm a newbe and have a simple @OneToMany relationship to build without using a Join-Table and where the PK of table 1 is part of the PK in table 2

table 1: Exchange , PK: id
table 2: ExchangeRetrievalDate, PK: exchangeId (Pk of Exchange) + date


@Entity
public class Exchange {
@Id
private Integer id;
@Column
private String code;
@OneToMany(cascade = CascadeType.ALL, fetch=FetchType.EAGER)
private List<ExchangeRetrievalDate> exchangeRetrievalDates;
}

@Entity
@IdClass(com.stockdomain.domain.ExchangeRetrievalDateCK.class)
public class ExchangeRetrievalDate {
@Id
private Integer exchangeId;
@Id
private Date lastRetrievaldate;

@ManyToOne
@JoinColumn(name = "exchangeId", insertable = false, updatable = false)
private Exchange exchange;
}

@Embeddable
public class ExchangeRetrievalDateCK implements Serializable {
private int exchangeId;
private Date lastRetrievaldate;
}


Hibernate throws the following exception:

Caused by: org.postgresql.util.PSQLException: ERROR: relation "public.exchange_exchangeretrievaldate" does not exist


Top
 Profile  
 
 Post subject: Re: @OneToMany primary key part of foreign key
PostPosted: Wed Nov 23, 2011 3:22 am 
Newbie

Joined: Wed Nov 23, 2011 3:05 am
Posts: 3
@OneToMany(cascade = CascadeType.ALL, fetch=FetchType.EAGER,mappedBy="exchange")

maybe exchange_exchangeretrievaldate table not create

_________________
上帝啊,带我走吧。


Top
 Profile  
 
 Post subject: Re: @OneToMany primary key part of foreign key
PostPosted: Thu Nov 24, 2011 12:49 pm 
Newbie

Joined: Thu Jul 28, 2011 2:54 pm
Posts: 12
The reason was that some DB fields had uppercase characters. I put all db column names in lowercase and all works fine.


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