• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

My first Hibernate app.. got a question..

 
Jack Daniel
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well, i thought let me try working on some example using Hibernate ORM...

I somehow made it work..
part of the code:



I get it working, only when i pass the connection like:
Session sess1=sf.openSession(conn);

if not i always get an error, saying
java.lang.UnsupportedOperationException: The user must supply a JDBC connection

So, i guess, something wrong with my hibernate.properties, i have got no clue where it is wrong..

this is where i am supplying the required information in hibernate.properties:




I know, people who are very comfortable with Hibernate, will definitely know what is going wrong..

I thank you very much for your help.. I appreciate.. :-)

I am using Websphere app server on AS400,.. DB2 included in AS400..
and since the tables are not Journaled, i commented the Transaction, which are not supported incase tables are not journaled,.. that is the problem with DB2 on AS400..when i think of using Hibernate..
 
Jack Daniel
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is from the console, if that might be useful:
Thanks again

 
Loren Rosen
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the second line of the console output says:
Environment I net.sf.hibernate.cfg.Environment loaded properties from resource hibernate.properties ...

but the property values that it loads are not the same as the ones you say are in the hibernate.properties file. Bear in mind in gets that file via the classpath. Perhaps it's finding some other hibernate.properties file earlier in the classpath?
 
Jack Daniel
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks loren,

but well, it is loading just the properties that i set:

## JNDI Datasource

hibernate.connection.datasource jdbc/jndiname
hibernate.connection.username user
hibernate.connection.password passwd

## DB2/400
hibernate.dialect net.sf.hibernate.dialect.DB2400Dialect
hibernate.connection.driver_class com.ibm.as400.access.AS400JDBCDriver
hibernate.connection.url jdbc:as400://systemName
hibernate.connection.username user
hibernate.connection.password passwd

here i just wrote some general data, but the true data, is showing on the 2nd line, so it is definitely loading the correct properties that i set;
but i am not sure what else is going wrong, in taking the connection from hibernate.properties...??

on the 16th line, too, it is saying:



looks like some configuration in my hibernate.properties is missing...

Thanks for your help..
 
Jack Daniel
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


gotcha...

well, the problem was in setting a new set of Properties after creating an instance of Configuration..



and one more thing... i had to comment also


If not, it is throwing an error saying:


Can anybody shed more light on the second point.. i appreciate your help..
thanks again
 
Theodore Casser
Ranch Hand
Posts: 1902
Hibernate Netbeans IDE PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This might be a silly question, but do you have equal signs between the names of the options and their values in the properties file on your system? (Just asking, since they don't appear in the ones you quoted, and I know mine has them on my local properties file.)
 
Jack Daniel
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Theodore ,

but that was not the problem... In a properties file, i guess '=' or ' ',both mean the same.. atleast in my case, both ways work..

Anyway, i figured out why



was giving trouble, It was in the selection of cache implementation,

Previously i selected


but this time i selected
and it eliminates the problem..

I am not sure on what basis, i have to choose a cache implementation??

Thanks..
 
Loren Rosen
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I looked this up and apparently it is legal to use whitespace instead of = to separate a property and its value.

I'd just leave the query cache turned off for now. It's not something you need to worry about as a beginner. But anyway, it looks like the error is coming from the app server, not from hibernate. Is there some other log file, or can you turn on more detailed logging or something?
 
Jack Daniel
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Loren , i think both of us posted at the same time, i have written something.. in my post before..

It apparently comes down to the selection of cache implementation, which solved the problem...

Thanks..

PS: i am liking hibernate...
 
Loren Rosen
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
EHcache has its own jar file, which I bet isn't in your classpath.

The most significant difference between cache providers is what concurrency policies they support. Most don't support full transactional isolation, for instance, or keep caches in synch between different machines in a cluster. The most detailed discussion I've seen that's specific to Hibernate is in the "Hibernate in Action" book.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic