I know this doesn't make sense, as many tutorials state that you can use the SecondaryTable annotation, however it does not work in sleep mode. I have a circuit like this:
@Entity
@Table(name="server")
@SecondaryTable(name="cluster", pkJoinColumns = { @PrimaryKeyJoinColumn(name = "uuid", referencedColumnName = "cluster_uuid") })
public class Server {
@Id
@Column(name = "uuid")
private String uuid;
@Column(name = "cluster_uuid")
private String clusterUuid;
@Column(name = "ip", table="cluster")
private String ip;
..... }
@Entity
@Table(name = "cluster")
public class Cluster {
@Id
@Column(name = "uuid")
private String uuid;
@Column(name = "ip")
private String ip;
.....
}
Server.clusterUuid is the foreign key for Cluster.uuid. I hope to get a server object that retrieves the ip column from the cluster by attaching Server.clusterUuid to Cluster.uuid.
Then a hibernation exception met me:
: org.hibernate.AnnotationException: SecondaryTable JoinColumn org.hibernate.cfg.annotations.TableBinder.bindFk(TableBinder.java:402) org.hibernate.cfg.annotations.EntityBinder.bindJoinToPersistentClass(EntityBinder.java:620) org.hibernate.cfg.annotations.EntityBinder.createPrimaryColumnsToSecondaryTable(EntityBinder.java:612)
, . Hibernate bugzilla 2010 , , , . , , JPA , JPA wikibook
JPA . @ . @Id , @Id . @Id column (s) @PrimaryKeyJoinColumn .
. , Hibernate , join.
- , ? .