Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Mapping entities

 
Hernán Quevedo
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • 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.
 
Aurelian Tutuianu
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On server logs says anything? On deploy to the ejb container?
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • 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: 31
  • Mark post as helpful
  • send pies
  • 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
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • 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: 31
  • Mark post as helpful
  • send pies
  • 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: 31
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic