Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [dali-dev] Writing named queries to the orm.xml

Chris,

Could you enter a bug for this? It looks like a race condition and in the UI we get lucky most of the time. Trying to do this in code isn't working out for you. We should be calling initialize in the GenericOrmEntity.addNamedQuery(int) method. In GenericJavaEntity we are correctly initializing things. This is something we could fix for Dali release 2.0.1.

thanks,
Karen

Christopher Jaun wrote:

Hello,

I'm working on a scenario where I need to write named queries to the orm.xml file.

In my project I have a simple java class with no JPA annotations in it, everything is defined in the orm. xml:

<entity class=/"entities.Department"/>
<attributes>
<id name=/"deptId"/></id>
</attributes>
</entity>

In my code I am doing the following:

NamedQuery newNamedQuery = entity.addNamedQuery(index);
newNamedQuery.setName(name);
newNamedQuery.setQuery(query);

Where entity is of type GenericOrmEntity.

I always get a null pointer in setName() because the queryResource is null. I see there is an initialize method that sets this value, however, I never see it being called in my scenario.

I use the same code as above to write named queries to the entity class when I have a GenericJavaEntity object and it works fine.

Is there a different way to write queries to the orm.xml?

Thanks,
Chris


------------------------------------------------------------------------

_______________________________________________
dali-dev mailing list
dali-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/dali-dev


Back to the top