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