Hello,
Please see the mapping below.
Is there any way to move the @OneToMany mapping into the @MappedSuperclass? I can't see how, because the @Where clause requires a constant value. I would like to do something like :
@Where(clause="entityClass=" + this.class.simpleName)
Thanks for any suggestions!
Hibernate version:
3.2.6.ga
Mapping documents:
Code:
@Entity
public class EntityLog implements Serializable {
@Id Integer id;
Integer entityId;
String entityClass;
}
@Entity
public class MyEntity extends BaseEntity implements Serializable {
@Id Integer id;
// Uni-directional OneToMany
@OneToMany
@JoinColumn(name="entityId")
@Where(clause="entityClass='MyEntity'")
private List<EntityLog> logEntries = new ArrayList<EntityLog>(0);
}
@MappedSuperclass
public class BaseEntity {
}
Name and version of the database you are using:Oracle 10G
The generated SQL (not really, but this is easier to read :-)Code:
select * from MyEntity e, EntityLog log
where log.entityId = e.entity.id
and log.entityClass = 'MyEntity'