Hi,
I have a class with many properties so I decided to group some of them using embedded objects.
The main class is the class Number and inside I added the class Configuration.
There a couple a relations in the Configuration class one OneToOne and other ManyToOne.
For the first one there is no problem, but with the second I got this error:
A component cannot hold properties split into 2 different tables: com.persistence.core.model.Number.config
I don't understand why I get this error, any clue?
Code:
public class Number(){
...
Configuration config = new Configuration();
@Embedded
public Configuration getConfig() {
return config;
}
public void setConfig(Configuration config) {
this.config = config;
}
...
}
@Embeddable
public class DidConfiguration implements Serializable {
...
private Uri uri;
@ManyToOne (fetch = FetchType.LAZY)
@JoinTable(
name = "number_uri",
joinColumns = @JoinColumn(name = "number_id"),
inverseJoinColumns = @JoinColumn(name = "uri_id")
)
public Uri getUri() {
return uri;
}
public void setUri(Uri uri) {
this.uri = uri;
}
...
}
On the other hand if instead of using a relation ManyToOne I use a ManyToMany, there is no such a problem.
Code:
private Set<Uri> uri = new HashSet<Uri>();
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(
name = "number_uri",
joinColumns = @JoinColumn(name = "number_id"),
inverseJoinColumns = @JoinColumn(name = "uri_id")
)
public Set<Uri> getUri() {
return uri;
}
public void setUri(Set<Uri> uri) {
this.uri = uri;
}
I'm using:
hibernate.annotations.version 3.4.0.GA
hibernate-commons-annotations 3.3.0.ga
hibernate.core.version 3.3.1.GA
hibernate.entitymanager.version 3.3.2.GA
hibernate.version 3.2.6.ga
Thanks for your help