1

As you can see in this topic, JPA how to supply inheritance relationships for embeddable objects, I have embeddable classes for each unit type. I have an entity A with following definition

@Entity
@Table(name = "class_x")
@PrimaryKeyJoinColumn(name = "class_x_id")
public class ClassX  {
/**
 * 
 */
private static final long serialVersionUID = -4924441463209260247L;

public ClassX  () {
    super();
}

@Column
private String name;


/** rated Apparent Power. */
@Embedded
@AttributeOverrides({
        @AttributeOverride(name = "value", column = @Column(name = "aColumn_value")),
        @AttributeOverride(name = "unit", column = @Column(name = "aColumn_unit")),
        @AttributeOverride(name = "multiplier", column = @Column(name = "aColumn_multiplier"))
})
private Temperature aColumn;
/** Reference short circuit voltage. */
@AttributeOverrides({
        @AttributeOverride(name = "value", column = @Column(name = "bColumn_value")),
        @AttributeOverride(name = "unit", column = @Column(name = "bColumn_unit")),
        @AttributeOverride(name = "multiplier", column = @Column(name = "bColumn_multiplier"))
})

private Percentage bColumn;

}

I configured hibernate to create tables from my entities with create-drop.class_x table is created , it has only have class_x_id and name columns. Columns of embeddable object are not created. I could not find any problem/solution about this.

Community
  • 1
  • 1
user725455
  • 465
  • 10
  • 36

1 Answers1

0

The problem is about my embeddable class definitions. I was using inherited embeddable objects. This does not work in JPA. Now, I have defined base abstract unit as MappedSuperClass. super classes are embeddable. So as a result embeddable objects are inherited from @mappedsuperclass. Actually I read that Jpa also does not suport this. But it works now .

user725455
  • 465
  • 10
  • 36