• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

questions about Hibernate

 
Grady Jamyson
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am new to Hibernate.
And I have a questions about using "schema.table".

For example, I have a database named DB.
And I want to store different schools data in it.
I use school number as schema.

I've done this using DB2 and Oracle with SQL (in a jsp or JavaBean),
for instance, "select schoolname from " + schoolNum + ".schooldata",
but I don't know how to do the same function with Hibernate.

Any ideals?
Thanks a lot.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hibernate Query Language (HQL) is very like SQL - there are a few syntactical differences, but generally they are pretty much the same. So you can write queries which will look familiar:

for example, which selects the property "mate" from the table "eg.Cat". The big difference between the two, which I think is what you are looking for, is you can follow the path of joins through the name of the property you select, for example:

which would select the property telephone, from the table address (presuming there are mapped joins between class, student and address).

Hibernate also allows straight SQL queries with the createSQLQuery method. SO you can still run SQL as you understand, however you remove the ablility for Hibernate to be truely portable if you do that.
[ June 02, 2004: Message edited by: Paul Sturrock ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic