Problem with JPA - entity type not found

Hi,

I’m trying to use JPA from JRuby. The persistence.xml is found and a
connection to the database is established. The problem: As soon as I try
to execute createQuery I get :

Exception Description: Error compiling the query [select v from
Vkprlists as v]. Unknown entity type [Vkprlists]

The java class name is ruby.Vkprlists and thats exactly what I have
copied into my persistence.xml file:

ruby.Vkprlists ......

Any ideas what I’m doing wrong ?

Regards
Roger

— Example —

require “java”
require ‘jruby/core_ext’

include_class “javax.persistence.EntityManagerFactory”
include_class “javax.persistence.Persistence”
include_class “javax.persistence.Entity”

class Vkprlists
def self.jpa!
annotation = {
javax.persistence.Entity => {},
javax.persistence.Table => {“name” => “vkprlists”}
}
add_class_annotation(annotation)
become_java!
end
end

Vkprlists.jpa!

emf = Persistence::createEntityManagerFactory(“WWV”)
em = emf.createEntityManager()

result = em.createQuery(“select v from Vkprlists as v”,
Vkprlists.java_class)

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

just reading your example and the error:

Unknown entity type [Vkprlists]

and the query is
result = em.createQuery(“select v from Vkprlists as v”,
Vkprlists.java_class)

I have the feeling it should be result = em.createQuery(“select v from
ruby.Vkprlists as v”, Vkprlists.java_class)

but it is wild guess - sorry if I am on the wrong track.

regards Kristian

On Sun, May 16, 2010 at 1:19 PM, Roger G. [email protected] wrote:

       Â
require “java”
      javax.persistence.Entity => {},
em = emf.createEntityManager()

result = em.createQuery(“select v from Vkprlists as v”, Vkprlists.java_class)

To unsubscribe from this list, please visit:

  http://xircles.codehaus.org/manage_email


Kristian Meier + Saumya Sharma + Sanuka Meier
Vadakkethu House,
Edayanmula West PO - 689532,
Pathanamthitta District, Kerala, INDIA

tel: +91 468 2319577

protect your privacy while searching the net: www.ixquick.com

         _=_
       q(-_-)p
        '_) (_`
        /__/  \
     _(<_   / )_
  (__\_\_|_/__)

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

but it is wild guess - sorry if I am on the wrong track.

regards Kristian

On Sun, May 16, 2010 at 1:19 PM, Roger G. [email protected] wrote:


No, the syntax is ok. It seems as if the persistence.xml isn’t properly
parsed.

For example “puts res.size” gives 0 and the error message should be
something like:

Entity class [class ruby.Vkprlists] has no primary key specified…

– Example ----
emf = Persistence::createEntityManagerFactory(“WWV”)
em = emf.createEntityManager()

res = emf.getMetamodel().getManagedTypes();

puts res.size => gives 0


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email