-->
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: @Embeddable problem with entity over 2 tables
PostPosted: Tue Feb 21, 2006 12:28 pm 
Newbie

Joined: Mon Nov 08, 2004 6:03 pm
Posts: 8
Hi I have an entity object that uses both the @Table and @SecondaryTable annotations because its data is backed by 2 tables. I have an embeddable object called Address that looks like:


Code:
@Embeddable(access=AccessType.PROPERTY)
public class Address implements Serializable {
    /** */
    private String street;
    ...

    public String getStreet() {
        return street;
    }

    public void setStreet(String street) {
        this.street = street;
    }

    ...


And my entity looks like this:

Code:
public User implements Serializable {
    ...

    @Embedded
    @Column(secondaryTable="User")
    public Address getContactAddress() {
        return contactAddress;
    }

    public void setContactAddress(Address address) {
        this.contactAddress = address;
    }

    ...
}


When I run I get the error:

Code:
Unknown column 'street' in 'field list'
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2928)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1571)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1666)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2994)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:936)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1166)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1082)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1067)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:1967)


If I simply and don't have my entity join between the 2 tables it works fine. So can I this, that is have an entity that joins across 2 tables and have an embeddable object thats data is contained in the secondary table?

Thanks for any help,
Mike


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 21, 2006 12:53 pm 
Newbie

Joined: Mon Nov 08, 2004 6:03 pm
Posts: 8
It works if I switch the address fields and put them in the main table (not the secondary table). But it doesn't work if the address fields happen to be in the secondary table.

Any ideas?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 01, 2006 10:45 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
you should define the secondary table on each property of the embedded object not on the address property like you did

_________________
Emmanuel


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.