Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] QueryByExample and inherited class properties..

I just want to reply to this email so that some other users could be
benefited with the solution, if they have this problem.

The reason why this was happening was that in my persistence.xml i had
         <exclude-unlisted-classes />
 and i didn't include the B class in it. Once i included in it it was
able to recognize the class and its properties.

I tried to set exclude-unlisted-class to false and then to true and
when running in a java SE env. it is not making any difference(havent
tried in a javaee container)and unless i include the class
specifically in the persistence.xml file it is not working. May be
someone can suggest a better way to do this , but am glad that it
works now.

Cheers
Vaidya





On Thu, May 31, 2012 at 5:43 PM, vaidya nathan <vaidyaatdst@xxxxxxxxx> wrote:
> I have a class A that inherits from B .B has a property called "BName"
> .I am trying to use the QueryByExample on A's instance and i set the
> name to be "BNameValue". When i use the ReadAllQuery in the following
> way
>
>          ReadAllQuery query = (exp == null ? new
> ReadAllQuery(qbe.getClass()) : new ReadAllQuery(qbe.getClass(), exp))
> ;
>            QueryByExamplePolicy qbePolicy = new QueryByExamplePolicy() ;
>
>            qbePolicy.addSpecialOperation(String.class, "likeIgnoreCase");
>            query.setExampleObject(qbe) ;
>            query.setQueryByExamplePolicy(qbePolicy) ;
>            query.setShouldFilterDuplicates(true) ;
>             query.getResult()
>
> I was expecting that it would query on B's name but the SQL i am
> seeing doesn't have any of the base class properties in it.. it just
> does all of A's properties but doesn't use any of B's property . Is
> there some thing different i should do to get the SQL to generate with
> B's name.
>
>
> @Entity
> public class B
> {
> @Column(name="BName", nullable=true, length=80)
>
> private String BName;
>
> }
>
> @Entity
> @DiscriminatorValue("K")
> public class A extends B
> {
>   id
> }
>
>
> my query is A a = new A();
> a.setBName("BName");
>
> my SQL query is "SELECT ID,DITYPE FROM A WHERE (DITYPE = ?)
>        bind => ["DITypeValue"]
>
> and its not including BName in its query.
>
> Why is eclipselink automatically not using any of the base class
> properties when generating the SQL?
>
> Cheers
> Vaidya


Back to the top