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: Embedded object and ManyToOne with join table problem
PostPosted: Fri Apr 09, 2010 6:33 am 
Newbie

Joined: Thu Oct 09, 2008 9:01 am
Posts: 3
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


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.