-->
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.  [ 1 post ] 
Author Message
 Post subject: Mapping a join table to a collection of components
PostPosted: Wed Feb 06, 2008 2:33 pm 
Beginner
Beginner

Joined: Fri Jan 26, 2007 3:16 pm
Posts: 24
Hi, I'm trying to follow exactly the example in the hibernate book "Java Persistence with Hibernate", Chapter 7, Section 7.2.3, p. 307 -> "Mapping the Join table to a Collection of components".

I have a value class called FooBar, that is a link between a Foo and a Bar, and contains an extra column of information.

It's like this:


Code:
@Embeddable
@org.hibernate.annotations.AccessType("field")
public class FooBar {

@org.hibernate.annotations.Parent
private Foo foo;

@ManyToOne
@JoinColumn(name = "BAR_ID", nullable=false, updatable=false)
private Bar bar;

@Column(name="EXTRA_STUFF")
private String stuff;

...etc.
}


Then in the Foo class (which is an Entity class), I have this:

Code:
@org.hibernate.annotations.CollectionOfElements
@JoinTable(name="FOO_ID", joinColumns=@JoinColumn(name="BAR_ID")
private Set<FooBar> fooBars;


This is *exactly* how the book describes it, but when I try to load this in hibernate-tools in eclipse, I get a SessionFactory error that complains that:

Quote:
org.hibernate.PropertyNotFoundException: Could not find a setter for property foo in class com.blah.FooBar


I explicitly set the AccessType to "field", so why isn't this working? I don't want to add setter methods...as this class should be immutable anyway.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.