Skip to main content

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

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



Back to the top