• 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

Hibernate session.CreateQuery fails with tablename is not mapped

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Everyone

I am facing an issue with Hibernate mapping.

I have the following code that tries to get all the Authors from the sql server table using the MS JDBC Driver.

The code snippet looks like this




Here is what the Authors.hbm.xml looks like



I get the following error in Eclipse "Authors is not mapped [from Authors]"
I am using Eclipse 3.3.0 along with Hibernate Tool 3.2.0 cr1.

Am i missing something ?

Thanks for looking into this
[ December 02, 2007: Message edited by: Bindesh Vijayan ]
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is you hibernate.cfg.xml in the base of your classpath?

Mark
 
Bindesh Nair
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes, since the following method works fine


It only fails when i try session.createQuery("from Authors");
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try

 
Bindesh Nair
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, but I already tried that and it failed too.

I think I will agree with Mark, it has something to do with improper classpath. Perhaps it could be that I am depending on Eclipse inbuilt compilation option and so unable to give correct classpath for the Hibernate Tool. And hence, it might be complaining about it.

I will write my own build script and set the classpath and see how it goes.

Thanks once again.
[ December 03, 2007: Message edited by: Bindesh Vijayan ]
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was just about to post what Jaikiran posted. using the fully qualified class name. Since you did that in the code that you said works.

But I am still in agreement with myself that this seems to be more an eclipse configuration thing that Hibernate. And I don't know Eclipse to really help out more.

Mark
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This may not be your problem but JPA/Hibernate threw a similar run-time error for me, and I was able to correct it. When I moved a shared package (the database layer) to its own project, it compiled correctly but JPA/Hibernate threw this same type of error at run-time. When I moved the package source back to where it was previously (within the main project) it worked again. I think that the persistence.xml local to the main project didn't know about the classes that were in the other project (the one to which I moved the package that contained the source mapping the class to the database for the class referenced in the exception). I'm experimenting with putting all code that accesses Hibernate into the database package, so that the main project need not reference Hibernate at all, and then making another attempt at moving the package to its own project. If this isn't helpful to you, perhaps it at least gets my own experience out there into the ether in case it might help someone.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try CreateSQLQuery
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My web app had the same behavior and I solved by adding antlr library.
 
There's a city wid manhunt for this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic