Hibernate 4.1.9 から奇妙なエラーが発生します。これが私のエンティティクラスの構造です:
@Entity
@Table( name = "security_grant", catalog = "security")
public class SecurityGrantDO implements Serializable
{
private long id;
private SecuritySubjectDO securitySubject;
@Id
@GeneratedValue( strategy = IDENTITY )
@Column( name = "id", unique = true, nullable = false )
public long getId()
{
return this.id;
}
public void setId( long id )
{
this.id = id;
}
@Column( name = "security_subject__id", nullable = false )
public SecuritySubjectDO getSecuritySubject()
{
return securitySubject;
}
public void setSecuritySubject( SecuritySubjectDO securitySubject )
{
this.securitySubject = securitySubject;
}
}
@Entity
@Table( name = "security_subject", catalog = "security")
public class SecuritySubjectDO implements Serializable
{
private long id;
private ObjectType domainObjectType;
private long domainObjectId;
@Id
@GeneratedValue( strategy = IDENTITY )
@Column( name = "id", unique = true, nullable = false )
public long getId()
{
return this.id;
}
public void setId( long id )
{
this.id = id;
}
@Column( name = "domain_object_type", nullable = false )
@Enumerated(EnumType.STRING)
public ObjectType getDomainObjectType()
{
return domainObjectType;
}
public void setDomainObjectType( ObjectType domainObjectType )
{
this.domainObjectType = domainObjectType;
}
@Column( name = "domain_object__id", nullable = false)
public long getDomainObjectId()
{
return domainObjectId;
}
public void setDomainObjectId( long domainObjectId )
{
this.domainObjectId = domainObjectId;
}
}
これが私のクエリです:
Query query = session.createQuery( "from SecurityGrantDO g where g.securitySubject.domainObjectId = :doid and " +
"g.securitySubject.domainObjectType = :dot" );
これが実行されると、Hibernate は以下をスローします。
org.hibernate.QueryException: プロパティを解決できませんでした: domainObjectId of: com.jelli.phoenix.model.security.SecurityGrantDO [com.jelli.phoenix.model.security.SecurityGrantDO から g.securitySubject.domainObjectId = :doid および g .securitySubject.domainObjectType = :ドット]
は?domainObjectId は SecurityGrantDO のプロパティではありません。これは SecuritySubjectDO のプロパティです。メッセージ自体はおそらく単なるバグだと思いますが、暗黙の結合が失敗するのはなぜですか?