Exception:
Caused by: org.hibernate.HibernateException: Missing column: col1 in schema.Table1 at org.hibernate.mapping.Table.validateColumns(Table.java:277) at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:1130) at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:139) at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:359) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1341) at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
Here is the hibernate mapping.
ClassA Mapping
@Entity @Table(name = "Table1") public class ClassA implements Serializable {
private ClassB _classB = null;
@Embedded @AttributeOverrides({ @AttributeOverride(name = "col1", column = @Column(name = "db_col1")), @AttributeOverride(name = "col2", column = @Column(name = "db_col2")) }) public ClassB getClassB() { return _classB; } }
Class B Mapping
@Embeddable public class ClassB implements Serializable {
private Long col1; private Long col2; private String col3; private String col4;
/** * @return the col1 */ @Column(updatable=false,insertable=false) public Long getCol1() { return col1; }
/** * @return the col1 */ @Column(updatable=false,insertable=false) public Long getCol2() { return col2; } ... respective setters. }
|