-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Problem with Hibernate filter in inheritance structure
PostPosted: Tue Jun 11, 2013 3:41 am 
Newbie

Joined: Tue Jun 11, 2013 3:37 am
Posts: 1
Hi

We have a problem with Hibernate filters in JBoss AS 7.2. It seems to me that this may be a bug. But it is also possible that i miss something.

Our data model has entities and requests for these entities. The table structure is like the following:

Code:
TABLE MY_ENTITY
  MY_ENTITY_ID VARCHAR(20)
  ....
 
TABLE REQUEST
  REQUEST_ID NUMBER(10)
  REQUEST_ENTITY VARCHAR(10)
  REQUEST_STATE VARCHAR(10)
  ...
 
TABLE MY_ENTITIY_REQUEST
  REQUEST_ID NUMBER(10)
  MY_ENTITY_ID VARCHAR(20)
  ...
 


In the Java code this results in the following JPA entities:

Code:
@Entity
@Table(name="MY_ENTITY")
public class MyEntity implements Serializable {

   @Column(name="MY_ENTITY_ID")
   @Id
   private String name;
   
   ....

}

@Entity
@Table(name="REQUEST")
public abstract class Request implements Serializable {

   @Column(name="REQUEST_ID")
   @Id
   private Long id;
   
   @Column(name="REQUEST_STATE")
   private String requestState;
   
   ....

}

@Entity
@Table(name="MY_ENTITY_REQUEST")
public class MyEntityRequest extends Request implements Serializable {

   @Column(name="MY_ENTITY_ID")
   private String myEntityId;
   
   ....

}


In the MyEntity class we now need a list of filtered requests (filtered by REQUEST_STATE). We tried this with hibernate filters:

Code:
@Entity
@Table(name="MY_ENTITY")
@FilterDefs({
   @FilterDef(name="openRequest")
})
@Filters({
   @Filter(name="openRequest", condition="{h}.REQUEST_STATE <> 'DONE'", aliases={@SqlFragmentAlias(alias="h", table="REQUEST")})
})
public class MyEntity implements Serializable {

   ....

    @OneToMany(fetch=FetchType.EAGER)
    @JoinColumn(name="MY_ENTITY_ID")
    @Filters({
       @Filter(name="openRequest", condition="{h}.REQUEST_STATE <> 'DONE'", aliases={@SqlFragmentAlias(alias="h", table="REQUEST")})
    })
    private Set<MyEntityRequest> openRequests;

}


Unfortunately this results in an exception:

Caused by: java.sql.SQLSyntaxErrorException: ORA-00904: "OPENREQUES4_1_"."REQUEST_STATE": ungültiger Bezeichner

I debugged the resulting SQL and found the the where clause is placed wrongly:

Code:
select *
from MY_ENTITY myEntity0_
left outer join MY_ENTITY_REQUEST openreques4_ on myEntity0_.MY_ENTITY_ID=openreques4_.MY_ENTITY_ID and openreques4_1_.REQUEST_STATE <> 'DONE'
left outer join REQUEST openreques4_1_ on openreques4_.REQUEST_ID=openreques4_1_.REQUEST_ID where myEntity0_.MY_ENTITY_ID=?


Is this a bug or do i miss something?

Thanks in advance
Christian


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.