• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Mapping entities

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey, guys.

Quick question: how do I map entities (POJOs with annotations like @Entity, @Table..., etc.) so hibernate doesn't tell me that someClass is not mapped?

I have this bean:


And when trying to do this:



It throws the exception


I know there is a NamedQuery but hibernate doesn't find it so I'm testing this way first.

Thanks.
 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
On server logs says anything? On deploy to the ejb container?
 
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you create/initialize your AnnotationConfiguration object, make sure the Java class is added prior to invoking config. Here I add a class named User:



Validating your Hibernate Development Environment Tutorial

-Cameron McKenzie
 
Hernán Quevedo
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks! It worked.
Nevertheless... now it tells me:



Line 54 in stateful session-bean says:


On the other hand, no tables are being generated in mysql/trackman scheme, even though I wrote, on the persistence.xml:


and the console tells me this:



I must be missing something...
 
Cameron Wallace McKenzie
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

java.lang.NoClassDefFoundError: ebs/trackman/entities/User



So, you get that when you run your code? That's easy to explain - your compiled User code is not on the runtime classpath. Make sure your JVM can see the compiled class at runtime.

-Cameron McKenzie
 
Hernán Quevedo
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey, thank you.

Anyway, I have done everything but the JVM doesn't seem to see it, no matter what.

How would you do it? It's amazing how complicated this had turned out to be,
 
Hernán Quevedo
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nope, scratch that...

I did it, it was a problem of locating configuration files correctly.

Now... I swear I saw the JBoss console telling me named queries were getting bounded. All of the sudden, it creates the tables and doesn't bind any named queries, I have to put them manually on the hbm.xml file but it is so much better to have them on their respectively entity-class java file, don't you think?

How do I do that again? I remember that when I managed to bind those named queries at the same time it created the tables, I had this exception telling me it couldn't resolve type java.util.Collection in a @ManyToOne annotation.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic