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..

To use <exclude-unlisted-classes>,

you need to set it to false,
and ensure that you persistence classes are packaged in the same jar file
that contains your persistence.xml,
then they should be discovered,
you can only use the <jar> element to include all of the classes in a jar
file in your persistence unit.


vaidya nathan wrote:
> 
> 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
> 
> 


-----
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland 
http://www.eclipse.org/eclipselink/
 EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink 
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink , 
http://wiki.oracle.com/page/TopLink TopLink 
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink , 
http://www.eclipse.org/forums/index.php?t=thread&frm_id=111&S=1b00bfd151289b297688823a00683aca
EclipseLink 
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence 
Blog:  http://java-persistence-performance.blogspot.com/ Java Persistence
Performance 
-- 
View this message in context: http://old.nabble.com/QueryByExample-and-inherited-class-properties..-tp33941865p33976126.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top