Raoua KHATERCHI (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=63482cf...
) *created* an issue
Hibernate Tools (
https://hibernate.atlassian.net/browse/HBX?atlOrigin=eyJpIjoiNzczODk5YTBk...
) / Bug (
https://hibernate.atlassian.net/browse/HBX-2415?atlOrigin=eyJpIjoiNzczODk...
) HBX-2415 (
https://hibernate.atlassian.net/browse/HBX-2415?atlOrigin=eyJpIjoiNzczODk...
) Hibernate default schema in @Filter conditions (
https://hibernate.atlassian.net/browse/HBX-2415?atlOrigin=eyJpIjoiNzczODk...
)
Issue Type: Bug Assignee: Koen Aers (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) Components: annotations (obsolete) Created: 29/Oct/2022 13:35 PM Priority: Major
Reporter: Raoua KHATERCHI (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=63482cf...
)
When I try to specify table aliases in filter conditions an exception is thrown says
account object not found because I don't specify the default schema.
@Entity(name = "Account" )
@Table(name = "account" )
@SecondaryTable(name = "account_details" )
@FilterDefs({
@FilterDef(name = "activeAccountV1" , parameters = @ParamDef(name =
"active" , type = " boolean " )),
@FilterDef(name = "activeAccountV2" , parameters = @ParamDef(name =
"active" , type = " boolean " ))})
@Filters({
@Filter(name = "activeAccountV1" , condition = "{a}.active = :active and
{ad}.deleted = false " , aliases = {
//@SqlFragmentAlias(alias = "a" , table = "account" ), --NOT OK
@SqlFragmentAlias(alias = "a" , table = "TEST.account" ), //OK
//@SqlFragmentAlias(alias = "ad" , table = "TEST.account_details"
), --NOT OK
@SqlFragmentAlias(alias = "ad" , table = "TEST.account_details" ),
//OK
}),
@Filter(name = "activeAccountV2" , condition = "{a}.active =
:active" , aliases = {
//@SqlFragmentAlias(alias = "a" , entity =AccountPO.class ) --NOT OK
@SqlFragmentAlias(alias = "a" , table = "TEST.account" ) //OK
})
})
public class AccountPO {
@Id
private Long id;
private Double amount;
private Double rate;
private boolean active;
@Column(table = "account_details" )
private boolean deleted;
}
As in the above code snippet I tried with entity parameter @SqlFragmentAlias( alias =
"a", entity= Account.class) and I faced another exeption [PersistenceUnit:
<default>] Unable to build Hibernate SessionFactory Caused by
org.hibernate.MappingException: Unknown entity: Account
I think we need a way how to dynamically get the current default schema.
As a reproducer:
git clone
https://github.com/raoua-eng/hibernate.git
cd hibernate
mvn clean test
(
https://hibernate.atlassian.net/browse/HBX-2415#add-comment?atlOrigin=eyJ...
) Add Comment (
https://hibernate.atlassian.net/browse/HBX-2415#add-comment?atlOrigin=eyJ...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100209- sha1:d23b292 )