Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • 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
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

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: 5006
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: 5006
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.
 
Always! Wait. Never. Shut up. Look at this tiny ad.
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic