Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [Teneo] Problem in using Named Queries
[Teneo] Problem in using Named Queries [message #425194] Wed, 19 November 2008 09:45 Go to next message
Eclipse UserFriend
Originally posted by: kalkar.prashant.gmail.com

Hi,

I am working on an application using Teneo (v 0.8.0), hibernate and EMF.
The application model is generated from XML schema, and the hibernate
mapping file is generated by using teneo plugin in eclipse.

I am trying to use the Named queries in the application but I am getting
following exception:

org.hibernate.MappingException: Named query not known:
getCustomerEventsQuery
at
org.hibernate.impl.AbstractSessionImpl.getNamedQuery(Abstrac tSessionImpl.java:70)
at org.hibernate.impl.SessionImpl.getNamedQuery(SessionImpl.jav a:1260)
at
com.giki.server.service.impl.CalendarServiceImpl.getNamedEve ntQuery(CalendarServiceImpl.java:153)
at
com.giki.server.service.impl.CalendarServiceImpl.getCustomer Events(CalendarServiceImpl.java:74)
.... 24 more

I have defined the named query as follows in hibernate.hbm.xml file:
</hibernate-mapping>
......
......
<query name="getCustomerEventsQuery">
<![CDATA[
from EventType event where event.timeReceived >=:fromDate and
event.timeReceived <= :toDate and event.customer.userToken = :userToken
order by event.timeReceived
]]>
</query>
</hibernate-mapping>

The query is correct and work properly when I used it to create
hibernate query object. I also tried to use the named queries in other
application using just hibernate (without teneo) it worked fine with
above steps.

Please help.

Regards,
Prashant
Re: [Teneo] Problem in using Named Queries [message #425216 is a reply to message #425194] Wed, 19 November 2008 22:17 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Prashant,
If you direct Teneo to use a mapping file and not generate the mapping at runtime then it just
passes the hbm.xml directly on to Hibernate without modifying it. So my first guess is that Teneo is
not picking up the mapping file. Did you set the correct option in Teneo? Can you debug the
datastore to see if it reads the mapping file and passes it on to hibernate?

gr. Martin

Prashant Kalkar wrote:
> Hi,
>
> I am working on an application using Teneo (v 0.8.0), hibernate and EMF.
> The application model is generated from XML schema, and the hibernate
> mapping file is generated by using teneo plugin in eclipse.
>
> I am trying to use the Named queries in the application but I am getting
> following exception:
>
> org.hibernate.MappingException: Named query not known:
> getCustomerEventsQuery
> at
> org.hibernate.impl.AbstractSessionImpl.getNamedQuery(Abstrac tSessionImpl.java:70)
>
> at org.hibernate.impl.SessionImpl.getNamedQuery(SessionImpl.jav a:1260)
> at
> com.giki.server.service.impl.CalendarServiceImpl.getNamedEve ntQuery(CalendarServiceImpl.java:153)
>
> at
> com.giki.server.service.impl.CalendarServiceImpl.getCustomer Events(CalendarServiceImpl.java:74)
>
> .... 24 more
>
> I have defined the named query as follows in hibernate.hbm.xml file:
> </hibernate-mapping>
> ......
> ......
> <query name="getCustomerEventsQuery">
> <![CDATA[
> from EventType event where event.timeReceived >=:fromDate and
> event.timeReceived <= :toDate and event.customer.userToken = :userToken
> order by event.timeReceived
> ]]>
> </query>
> </hibernate-mapping>
>
> The query is correct and work properly when I used it to create
> hibernate query object. I also tried to use the named queries in other
> application using just hibernate (without teneo) it worked fine with
> above steps.
>
> Please help.
>
> Regards,
> Prashant


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [Teneo] Problem in using Named Queries [message #425224 is a reply to message #425216] Thu, 20 November 2008 05:00 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: kalkar.prashant.gmail.com

Hi Martin,

Thanks for your reply.

I am not generating the mapping file at runtime. I generate the mapping
file using the eclipse Teneo plugin using the ecore file.

How to direct teneo to use the mapping file? I just put the mapping file
in the application classpath (in the source directory).

Also can you tell me what option need to set in Teneo and how to set
them? And how can I debug the datastore to find out the problem.

I am using hibernate.properties file and its contents are as follows (it
also present in the application source directory):

hibernate.connection.driver_class=com.mysql.jdbc.Driver
hibernate.connection.url=jdbc:mysql://127.0.0.1:3306/myapp
hibernate.connection.username=<username>
hibernate.connection.password=<password>
hibernate.dialect=org.hibernate.dialect.MySQLDialect

Following is the code used to create the hibernate session factory:

final String dataStoreName = "dataStoreName";
final HbDataStore dataStore =
HbHelper.INSTANCE.createRegisterDataStore(dataStoreName);

// Configure the EPackages used by this DataStore.
dataStore.setEPackages(new EPackage[] {
GikidocPackage.eINSTANCE });

// Initialize the DataStore. This sets up the Hibernate
mapping and
// creates the corresponding tables in the database.
dataStore.initialize();
sessionFactory = dataStore.getSessionFactory();

Please help me to resolve the issue.

Thanks & Regards,
Prashant

Martin Taal wrote:
> Hi Prashant,
> If you direct Teneo to use a mapping file and not generate the mapping
> at runtime then it just passes the hbm.xml directly on to Hibernate
> without modifying it. So my first guess is that Teneo is not picking up
> the mapping file. Did you set the correct option in Teneo? Can you debug
> the datastore to see if it reads the mapping file and passes it on to
> hibernate?
>
> gr. Martin
>
> Prashant Kalkar wrote:
>> Hi,
>>
>> I am working on an application using Teneo (v 0.8.0), hibernate and
>> EMF. The application model is generated from XML schema, and the
>> hibernate mapping file is generated by using teneo plugin in eclipse.
>>
>> I am trying to use the Named queries in the application but I am
>> getting following exception:
>>
>> org.hibernate.MappingException: Named query not known:
>> getCustomerEventsQuery
>> at
>> org.hibernate.impl.AbstractSessionImpl.getNamedQuery(Abstrac tSessionImpl.java:70)
>>
>> at org.hibernate.impl.SessionImpl.getNamedQuery(SessionImpl.jav a:1260)
>> at
>> com.giki.server.service.impl.CalendarServiceImpl.getNamedEve ntQuery(CalendarServiceImpl.java:153)
>>
>> at
>> com.giki.server.service.impl.CalendarServiceImpl.getCustomer Events(CalendarServiceImpl.java:74)
>>
>> .... 24 more
>>
>> I have defined the named query as follows in hibernate.hbm.xml file:
>> </hibernate-mapping>
>> ......
>> ......
>> <query name="getCustomerEventsQuery">
>> <![CDATA[
>> from EventType event where event.timeReceived >=:fromDate and
>> event.timeReceived <= :toDate and event.customer.userToken =
>> :userToken order by event.timeReceived
>> ]]>
>> </query>
>> </hibernate-mapping>
>>
>> The query is correct and work properly when I used it to create
>> hibernate query object. I also tried to use the named queries in other
>> application using just hibernate (without teneo) it worked fine with
>> above steps.
>>
>> Please help.
>>
>> Regards,
>> Prashant
>
>
Re: [Teneo] Problem in using Named Queries [message #425229 is a reply to message #425224] Thu, 20 November 2008 10:25 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Prashant,
There should be a class PersistenceOptions which should have an option like USE_MAPPING_FILE, you
have to set this option to "true" and pass it on to the datastore (setPersistenceProperties method).
The datastore is not a very big class, there is a piece of code which uses the above option and
calls another method to retrieve the hbm file and pass it on to the configuration object. There is a
utility method which is called whcih walks through the classpath of the model classes, so if your
generated model package is in org.my.model.package.impl then teneo will search here:
org.my.model.package.impl
org.my.model.package
org.my.model
org.my
org

So your hibernate.hbm.xml should be in the above path somewhere.

Be sure to have the hibernate.hbm.xml checked in the build.properties so that it is copied to the
build path.

Btw, the exact naming of the methods I refer to maybe slightly different as I don't have the 0.8.0
source code directly available where I am now.

gr. Martin

Prashant Kalkar wrote:
> Hi Martin,
>
> Thanks for your reply.
>
> I am not generating the mapping file at runtime. I generate the mapping
> file using the eclipse Teneo plugin using the ecore file.
>
> How to direct teneo to use the mapping file? I just put the mapping file
> in the application classpath (in the source directory).
>
> Also can you tell me what option need to set in Teneo and how to set
> them? And how can I debug the datastore to find out the problem.
>
> I am using hibernate.properties file and its contents are as follows (it
> also present in the application source directory):
>
> hibernate.connection.driver_class=com.mysql.jdbc.Driver
> hibernate.connection.url=jdbc:mysql://127.0.0.1:3306/myapp
> hibernate.connection.username=<username>
> hibernate.connection.password=<password>
> hibernate.dialect=org.hibernate.dialect.MySQLDialect
>
> Following is the code used to create the hibernate session factory:
>
> final String dataStoreName = "dataStoreName";
> final HbDataStore dataStore =
> HbHelper.INSTANCE.createRegisterDataStore(dataStoreName);
>
> // Configure the EPackages used by this DataStore.
> dataStore.setEPackages(new EPackage[] {
> GikidocPackage.eINSTANCE });
>
> // Initialize the DataStore. This sets up the Hibernate
> mapping and
> // creates the corresponding tables in the database.
> dataStore.initialize();
> sessionFactory = dataStore.getSessionFactory();
>
> Please help me to resolve the issue.
>
> Thanks & Regards,
> Prashant
>
> Martin Taal wrote:
>> Hi Prashant,
>> If you direct Teneo to use a mapping file and not generate the mapping
>> at runtime then it just passes the hbm.xml directly on to Hibernate
>> without modifying it. So my first guess is that Teneo is not picking
>> up the mapping file. Did you set the correct option in Teneo? Can you
>> debug the datastore to see if it reads the mapping file and passes it
>> on to hibernate?
>>
>> gr. Martin
>>
>> Prashant Kalkar wrote:
>>> Hi,
>>>
>>> I am working on an application using Teneo (v 0.8.0), hibernate and
>>> EMF. The application model is generated from XML schema, and the
>>> hibernate mapping file is generated by using teneo plugin in eclipse.
>>>
>>> I am trying to use the Named queries in the application but I am
>>> getting following exception:
>>>
>>> org.hibernate.MappingException: Named query not known:
>>> getCustomerEventsQuery
>>> at
>>> org.hibernate.impl.AbstractSessionImpl.getNamedQuery(Abstrac tSessionImpl.java:70)
>>>
>>> at org.hibernate.impl.SessionImpl.getNamedQuery(SessionImpl.jav a:1260)
>>> at
>>> com.giki.server.service.impl.CalendarServiceImpl.getNamedEve ntQuery(CalendarServiceImpl.java:153)
>>>
>>> at
>>> com.giki.server.service.impl.CalendarServiceImpl.getCustomer Events(CalendarServiceImpl.java:74)
>>>
>>> .... 24 more
>>>
>>> I have defined the named query as follows in hibernate.hbm.xml file:
>>> </hibernate-mapping>
>>> ......
>>> ......
>>> <query name="getCustomerEventsQuery">
>>> <![CDATA[
>>> from EventType event where event.timeReceived >=:fromDate and
>>> event.timeReceived <= :toDate and event.customer.userToken =
>>> :userToken order by event.timeReceived
>>> ]]>
>>> </query>
>>> </hibernate-mapping>
>>>
>>> The query is correct and work properly when I used it to create
>>> hibernate query object. I also tried to use the named queries in
>>> other application using just hibernate (without teneo) it worked fine
>>> with above steps.
>>>
>>> Please help.
>>>
>>> Regards,
>>> Prashant
>>
>>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [Teneo] Problem in using Named Queries [message #425298 is a reply to message #425229] Sat, 22 November 2008 04:52 Go to previous message
Eclipse UserFriend
Originally posted by: kalkar.prashant.gmail.com

Hi Martin,

It worked. I made the required changes in the code to initialize the
datastore and the application can now read the hibernate.hbm.xml file.

Thanks for your help.

Thanks & Regards,
Prashant

Martin Taal wrote:
> Hi Prashant,
> There should be a class PersistenceOptions which should have an option
> like USE_MAPPING_FILE, you have to set this option to "true" and pass it
> on to the datastore (setPersistenceProperties method). The datastore is
> not a very big class, there is a piece of code which uses the above
> option and calls another method to retrieve the hbm file and pass it on
> to the configuration object. There is a utility method which is called
> whcih walks through the classpath of the model classes, so if your
> generated model package is in org.my.model.package.impl then teneo will
> search here:
> org.my.model.package.impl
> org.my.model.package
> org.my.model
> org.my
> org
>
> So your hibernate.hbm.xml should be in the above path somewhere.
>
> Be sure to have the hibernate.hbm.xml checked in the build.properties so
> that it is copied to the build path.
>
> Btw, the exact naming of the methods I refer to maybe slightly different
> as I don't have the 0.8.0 source code directly available where I am now.
>
> gr. Martin
>
> Prashant Kalkar wrote:
>> Hi Martin,
>>
>> Thanks for your reply.
>>
>> I am not generating the mapping file at runtime. I generate the
>> mapping file using the eclipse Teneo plugin using the ecore file.
>>
>> How to direct teneo to use the mapping file? I just put the mapping
>> file in the application classpath (in the source directory).
>>
>> Also can you tell me what option need to set in Teneo and how to set
>> them? And how can I debug the datastore to find out the problem.
>>
>> I am using hibernate.properties file and its contents are as follows
>> (it also present in the application source directory):
>>
>> hibernate.connection.driver_class=com.mysql.jdbc.Driver
>> hibernate.connection.url=jdbc:mysql://127.0.0.1:3306/myapp
>> hibernate.connection.username=<username>
>> hibernate.connection.password=<password>
>> hibernate.dialect=org.hibernate.dialect.MySQLDialect
>>
>> Following is the code used to create the hibernate session factory:
>>
>> final String dataStoreName = "dataStoreName";
>> final HbDataStore dataStore =
>> HbHelper.INSTANCE.createRegisterDataStore(dataStoreName);
>>
>> // Configure the EPackages used by this DataStore.
>> dataStore.setEPackages(new EPackage[] {
>> GikidocPackage.eINSTANCE });
>>
>> // Initialize the DataStore. This sets up the Hibernate
>> mapping and
>> // creates the corresponding tables in the database.
>> dataStore.initialize();
>> sessionFactory = dataStore.getSessionFactory();
>>
>> Please help me to resolve the issue.
>>
>> Thanks & Regards,
>> Prashant
>>
>> Martin Taal wrote:
>>> Hi Prashant,
>>> If you direct Teneo to use a mapping file and not generate the
>>> mapping at runtime then it just passes the hbm.xml directly on to
>>> Hibernate without modifying it. So my first guess is that Teneo is
>>> not picking up the mapping file. Did you set the correct option in
>>> Teneo? Can you debug the datastore to see if it reads the mapping
>>> file and passes it on to hibernate?
>>>
>>> gr. Martin
>>>
>>> Prashant Kalkar wrote:
>>>> Hi,
>>>>
>>>> I am working on an application using Teneo (v 0.8.0), hibernate and
>>>> EMF. The application model is generated from XML schema, and the
>>>> hibernate mapping file is generated by using teneo plugin in eclipse.
>>>>
>>>> I am trying to use the Named queries in the application but I am
>>>> getting following exception:
>>>>
>>>> org.hibernate.MappingException: Named query not known:
>>>> getCustomerEventsQuery
>>>> at
>>>> org.hibernate.impl.AbstractSessionImpl.getNamedQuery(Abstrac tSessionImpl.java:70)
>>>>
>>>> at org.hibernate.impl.SessionImpl.getNamedQuery(SessionImpl.jav a:1260)
>>>> at
>>>> com.giki.server.service.impl.CalendarServiceImpl.getNamedEve ntQuery(CalendarServiceImpl.java:153)
>>>>
>>>> at
>>>> com.giki.server.service.impl.CalendarServiceImpl.getCustomer Events(CalendarServiceImpl.java:74)
>>>>
>>>> .... 24 more
>>>>
>>>> I have defined the named query as follows in hibernate.hbm.xml file:
>>>> </hibernate-mapping>
>>>> ......
>>>> ......
>>>> <query name="getCustomerEventsQuery">
>>>> <![CDATA[
>>>> from EventType event where event.timeReceived >=:fromDate and
>>>> event.timeReceived <= :toDate and event.customer.userToken =
>>>> :userToken order by event.timeReceived
>>>> ]]>
>>>> </query>
>>>> </hibernate-mapping>
>>>>
>>>> The query is correct and work properly when I used it to create
>>>> hibernate query object. I also tried to use the named queries in
>>>> other application using just hibernate (without teneo) it worked
>>>> fine with above steps.
>>>>
>>>> Please help.
>>>>
>>>> Regards,
>>>> Prashant
>>>
>>>
>
>
Previous Topic:Problems caused by the call to the factory as part of the collectNewChildDescriptors in the Edit Plu
Next Topic:Quick Fix Resolutions for custom markers
Goto Forum:
  


Current Time: Sun Feb 23 02:33:36 GMT 2020

Powered by FUDForum. Page generated in 0.01818 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top