-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 24 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: How can i integrate Hibernate 3 to JDeveloper 10g?
PostPosted: Thu Aug 04, 2005 2:36 pm 
Beginner
Beginner

Joined: Thu Aug 04, 2005 2:24 pm
Posts: 45
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
3
Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:
Oracle 9.1.2
The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

Hi all,

I'm trying to integrate Hibernate do my MVC(Struts) model application in JDeveloper 10g. Is it possible? or i have to use TopLink?

I apologize if this already has been answered, i searched for it but didn't find it.

I have hibernate 3 and its extensions downloaded and extracted to some folder.

Thanks to all

_________________
Eduardo Mylonas


Top
 Profile  
 
 Post subject: Re: How can i integrate Hibernate 3 to JDeveloper 10g?
PostPosted: Thu Aug 04, 2005 2:55 pm 
Beginner
Beginner

Joined: Tue Jul 12, 2005 10:27 am
Posts: 23
emylonas wrote:
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
3
Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:
Oracle 9.1.2
The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

Hi all,

I'm trying to integrate Hibernate do my MVC(Struts) model application in JDeveloper 10g. Is it possible? or i have to use TopLink?

I apologize if this already has been answered, i searched for it but didn't find it.

I have hibernate 3 and its extensions downloaded and extracted to some folder.

Thanks to all


Hibernate can work in a managed or unmanaged environment. If you're using Struts, you might want to read up on the Session View pattern and write a Plugin for strings to load and configure Hibernate as a one shot deal. If you're asking how to get Hibernate to work in your IDE, just make sure the classpaths are correct so it finds the mapping file and configuration file.

_________________
- Richard Burton


Top
 Profile  
 
 Post subject: Re: How can i integrate Hibernate 3 to JDeveloper 10g?
PostPosted: Fri Aug 05, 2005 7:36 am 
Beginner
Beginner

Joined: Thu Aug 04, 2005 2:24 pm
Posts: 45
RichardBurton79 wrote:
Hibernate can work in a managed or unmanaged environment. If you're using Struts, you might want to read up on the Session View pattern and write a Plugin for strings to load and configure Hibernate as a one shot deal. If you're asking how to get Hibernate to work in your IDE, just make sure the classpaths are correct so it finds the mapping file and configuration file.


OK. Do i still have to go through the installation process described in hibernate.org? I know this may sound like a dumb question... but i'm a little hesitant about taking any action for granted due to sometimes undoing or correcting these things are sometimes more difficult than doing it right from the start.

Thanks a lot for you reply.

_________________
Eduardo Mylonas


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 05, 2005 7:40 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
If you haven't followed this, please do so before worrying about things related to your IDE: http://www.hibernate.org/152.html


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 05, 2005 10:30 am 
Beginner
Beginner

Joined: Thu Aug 04, 2005 2:24 pm
Posts: 45
christian wrote:
If you haven't followed this, please do so before worrying about things related to your IDE: http://www.hibernate.org/152.html


Well, i did what it said: Edit hibernate.properties and run build.bat

The following messages were printed on screen. I don't know if that's a problem:
---------------------------------
D:\Hibernate\hibernate-3.0>java -cp "lib/ant-launcher-1.6.3.jar" o
rg.apache.tools.ant.launch.Launcher -lib lib -Ddriver.jar=jdbc/hsqldb.jar
Buildfile: build.xml
[taskdef] Could not load definitions from resource checkstyletask.properties.
It could not be found.
[taskdef] Could not load definitions from resource clovertasks. It could not b
e found.
---------------------------------

Anyway, i'll proceed with trying to integrate hibernate with jdev now.

Thanks a lot :)

_________________
Eduardo Mylonas


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 05, 2005 10:52 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Both are just warnings, ignore them. What follows is important, you cut that off in your posting.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 05, 2005 11:00 am 
Beginner
Beginner

Joined: Thu Aug 04, 2005 2:24 pm
Posts: 45
christian wrote:
Both are just warnings, ignore them. What follows is important, you cut that off in your posting.


ooooh, sorry. but not so much was printed. it returned a success message at the end. also it created a new hibernate folder with the hibernate3.jar inside it. i believe that's ok, right?

also, i have already placed this hibernate3.jar and my hibernate.properties and the log4j.properties file in the project classpath.

i'm now trying to run the example in hibernate.org. it is compiling the classes that reference hibernate. i feel i'm going alright...

Thanks a lot

_________________
Eduardo Mylonas


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 05, 2005 11:05 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Please take some time and follow _all_ the steps from the Getting Started page. Including the tutorials!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 05, 2005 12:30 pm 
Beginner
Beginner

Joined: Thu Aug 04, 2005 2:24 pm
Posts: 45
christian wrote:
Please take some time and follow _all_ the steps from the Getting Started page. Including the tutorials!


Ok. I'm doing that now.

Thanks a lot

_________________
Eduardo Mylonas


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 05, 2005 4:04 pm 
Beginner
Beginner

Joined: Thu Aug 04, 2005 2:24 pm
Posts: 45
emylonas wrote:
christian wrote:
Please take some time and follow _all_ the steps from the Getting Started page. Including the tutorials!


Ok. I'm doing that now.

Thanks a lot


OK, now i'm stuck at "2.2.6. Loading and storing objects" in the "Introduction do Hibernate". These errors are coming up when compiling my files:

Error(29,43): incompatible types; found: org.hibernate.classic.Session, required: org.hibernate.SessionFactory
This one points to this line "s = sessionFactory.openSession();" in HibernateUtil.java

Error(26,51): method beginTransaction not found in interface org.hibernate.SessionFactory
This one points to "TransactionRequiredException tx = session.beginTransaction();" in EventManager.java

Error(32,17): method save(testehibernate.model.Event) not found in interface org.hibernate.SessionFactory
This one points to "session.save(theEvent);" also in EventManager.java

Error(34,12): method commit not found in class javax.transaction.TransactionRequiredException
Ant this last one points to "tx.commit();" in the same file.

Obviously i'm missing something. I have already done pretty much all the useless things. it seems that all that is left now is the right thing. Trying to figure out what it is...

Thanks a lot

_________________
Eduardo Mylonas


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 05, 2005 4:22 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Double check the code, this is certainly not what was in the tutorial. I'm sorry, but those are all very very trivial Java errors. If you have no experience with Java at all you should probably invest time into some other material as well.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 08, 2005 7:56 am 
Beginner
Beginner

Joined: Thu Aug 04, 2005 2:24 pm
Posts: 45
christian wrote:
Double check the code, this is certainly not what was in the tutorial. I'm sorry, but those are all very very trivial Java errors. If you have no experience with Java at all you should probably invest time into some other material as well.


I'm sorry for setting the most rude mannors inside of you. I came here for help and the only reason i posted the message above is because i't is indeed pretty basic Java Errors. I have already thought of the possibility of the tutorial be written for version 2, when i'm using version 3.

If you find yourself in a position of judging people's experience without knowing them, i can only hope for the best in your life. I get sad to believe you encourage people not use your technology just by reading a few lines and not understanding the problem. But don't worry, i know how far i can go, despite the behaviour of some people.

The problem here is that the messages printed are like i'm using the wrong method calls. But these methods were copied from the tutorial here.

This is what there is in the tutorial:
import org.hibernate.Session;
...
private void createAndStoreEvent(String title, Date theDate)
{
Session session = HibernateUtil.currentSession();
Transaction tx = session.beginTransaction();

Event theEvent = new Event();
theEvent.setTitle(title);
theEvent.setDate(theDate);

session.save(theEvent);

tx.commit();
HibernateUtil.closeSession();
}

But the compiler prints the message: "Error(27,55): incompatible types; found: org.hibernate.SessionFactory, required: org.hibernate.Session" and it points to the line "Session session = HibernateUtil.currentSession();". of course this is pretty basic Java problem, but you can see i'm declaring a variable Session and the compiler says what's declared is SessionFactory... I hope you can see my problem now.

Thanks a lot

_________________
Eduardo Mylonas


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 08, 2005 7:59 am 
Beginner
Beginner

Joined: Thu Aug 04, 2005 2:24 pm
Posts: 45
emylonas wrote:
christian wrote:
Double check the code, this is certainly not what was in the tutorial. I'm sorry, but those are all very very trivial Java errors. If you have no experience with Java at all you should probably invest time into some other material as well.


I'm sorry for setting the most rude mannors inside of you. I came here for help and the only reason i posted the message above is because i't is indeed pretty basic Java Errors. I have already thought of the possibility of the tutorial be written for version 2, when i'm using version 3.

If you find yourself in a position of judging people's experience without knowing them, i can only hope for the best in your life. I get sad to believe you encourage people not use your technology just by reading a few lines and not understanding the problem. But don't worry, i know how far i can go, despite the behaviour of some people.

The problem here is that the messages printed are like i'm using the wrong method calls. But these methods were copied from the tutorial here.

This is what there is in the tutorial:
import org.hibernate.Session;
...
private void createAndStoreEvent(String title, Date theDate)
{
Session session = HibernateUtil.currentSession();
Transaction tx = session.beginTransaction();

Event theEvent = new Event();
theEvent.setTitle(title);
theEvent.setDate(theDate);

session.save(theEvent);

tx.commit();
HibernateUtil.closeSession();
}

But the compiler prints the message: "Error(27,55): incompatible types; found: org.hibernate.SessionFactory, required: org.hibernate.Session" and it points to the line "Session session = HibernateUtil.currentSession();". of course this is pretty basic Java problem, but you can see i'm declaring a variable Session and the compiler says what's declared is SessionFactory... I hope you can see my problem now.

Thanks a lot


And now you can see that the problem was so basic and i couldn't understand that closing and reopening the application solved the problem. I wish i could have saved your behaviour.

Thanks a lot

_________________
Eduardo Mylonas


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 08, 2005 8:03 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Your HibernateUtil class is not correct, because it obviously does return a SessionFactory when you ask it for a Session. You probably made some mistake when copy/pasting it from the tutorial. You probably have many other trivial mistakes in your code as well, judging from the other errors you get.

Since you get easily upset if someone points out these things to you, find someone else to help you from now on.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 08, 2005 9:13 am 
Beginner
Beginner

Joined: Thu Aug 04, 2005 2:24 pm
Posts: 45
christian wrote:
Your HibernateUtil class is not correct, because it obviously does return a SessionFactory when you ask it for a Session. You probably made some mistake when copy/pasting it from the tutorial. You probably have many other trivial mistakes in your code as well, judging from the other errors you get.

Since you get easily upset if someone points out these things to you, find someone else to help you from now on.


If i were upset, i wouldn't keep going through the tutorial. I believe one can do and say whatever one's want. What matters is not "what is done", but "how things are done". Pointing out possible mistakes on the code is one thing, disencouraging someone to use Hibernate is not the adequate behaviour to a technical support person.

I'm working with JDeveloper, and due to prior errors, it automatically made a few changes to my imports and the code i copied from the tutorial. That was the problem.

As for looking somewhere else for answers, i'll execute my right to keep asking here, once this is supposed the best place to look for answers on Hibernate. Please, feel free to exercise you rights, in case you don't feel like ansering them. I'll keep thanking any kind of help.

Right now, for example, i have this output:
Buildfile: build.xml

clean:
[delete] Deleting directory D:\Program Files\JDeveloper\jdev\mywork\Teste Hi
ernate\Model\bin
[mkdir] Created dir: D:\Program Files\JDeveloper\jdev\mywork\Teste Hibernat
\Model\bin

copy-resources:
[copy] Copying 3 files to D:\Program Files\JDeveloper\jdev\mywork\Teste Hi
ernate\Model\bin

compile:
[javac] Compiling 3 source files to D:\Program Files\JDeveloper\jdev\mywork
Teste Hibernate\Model\bin

run:
[java] java.lang.NoClassDefFoundError: EventManager
[java] Exception in thread "main"
[java] Java Result: 1

BUILD SUCCESSFUL
Total time: 2 seconds

I don't understand how it can not find the EventManager class, since the main method is within it. I'll keep digging.

Thanks a lot

_________________
Eduardo Mylonas


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 24 posts ]  Go to page 1, 2  Next

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.