-->
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.  [ 26 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Including mapping files with the Hibernate Eclipse plugin
PostPosted: Wed Mar 29, 2006 4:33 pm 
Beginner
Beginner

Joined: Thu Feb 23, 2006 11:22 am
Posts: 30
The Hiberate plug-in looks like a fantastic tool, and I really want everyone in the company to use it but I am having problems understanding something.

There are two ways to enter mapping information, the Create Hibernate Console Configuration screen and the hibernate.cfg.xml configuration tab..

When I double click on the hibernate.cfg.xml file. This opens the file and brings me into the configuration tab which has a pane for Mapping files.
If I use the Mapping Files section of the hibernate.cfg.xml configuration tab I can see the changes made in the hibernate.cfg.xml but this causes the Hibernate Console Perspective to fail. The Hibernate Console Perspective says that it cannot find the file I just added to the hibernate.cfg.xml and will not open up the tree.. .

If I remove that mapping file from the hibernate.cfg.xml the Hibernate Console Perspective now works. Double clicking on the Hibernate Console Perspective brings up the screen that I used to create this Hibernate Console Configuration. Adding the mapping files into this screen allows them to be displayed in the configuration tab but there are no mapping properties in the hibernate.cfg.xml.

Which mechanism is the right one to use. I can not use both, they seem to conflict??. I need to get these mapping to the hibernate.cfg.xml but if I am to use this tool to execute HQL query statement I have to have them defined in the Hibernate Console Configuration tool. ???

I think that this is a class path problem but I do not seem to be able to get these things working..

Thanks in advance


Top
 Profile  
 
 Post subject: more data which may help
PostPosted: Wed Mar 29, 2006 4:48 pm 
Beginner
Beginner

Joined: Thu Feb 23, 2006 11:22 am
Posts: 30
1). I can see the database tables in my Hibernate Configuration Perspective, but my Hibernate Entity Model is totally blank.

2). Adding mapped classes into the Configuration tree of the Hibernate Console Perspective will have them show up there but now the Open HQL Scratchpad is disabled and I get a “Session Factory error: entity class not found” referring to one of the classes that I just added.

3). If I click on the Hibernate Dynamic Query Translator I get no HQL editor..

The entire purpose for me to use this tool is to learn and practice doing HQL queries and tune them. I have thousands, over 2000, SQL queries that I need to convert to HQL so a tool like this is invaluable. If I can get it to work.


Top
 Profile  
 
 Post subject: more data which may help
PostPosted: Wed Mar 29, 2006 4:48 pm 
Beginner
Beginner

Joined: Thu Feb 23, 2006 11:22 am
Posts: 30
1). I can see the database tables in my Hibernate Configuration Perspective, but my Hibernate Entity Model is totally blank.

2). Adding mapped classes into the Configuration tree of the Hibernate Console Perspective will have them show up there but now the Open HQL Scratchpad is disabled and I get a “Session Factory error: entity class not found” referring to one of the classes that I just added.

3). If I click on the Hibernate Dynamic Query Translator I get no HQL editor..

The entire purpose for me to use this tool is to learn and practice doing HQL queries and tune them. I have thousands, over 2000, SQL queries that I need to convert to HQL so a tool like this is invaluable. If I can get it to work.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 30, 2006 5:11 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
"When I double click on the hibernate.cfg.xml file. This opens the file and brings me into the configuration tab which has a pane for Mapping files."

We don't have an editor for hibernate.cfg.xml files yet. Are you sure you don't have some additional plugins installed ?

In any case, hibernate.cfg.xml file just lists the mapping files you want to load from your application.

If the hibernate console perspective fails on that it is beause those files are not available via the classpath specified on the console configuration.

The mapping file list shown in the hibernate console is *additional* mappings you want to load on top of what is in hibernate.cfg.xml. You often do not need this (I will move that list into a seperate dialog in the future to not confuse people)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 30, 2006 10:13 am 
Beginner
Beginner

Joined: Thu Feb 23, 2006 11:22 am
Posts: 30
WHAT!! GOOD GREIF !!
Okay.. Calm. Calm.. oh man.. okay.. I am good with this..

I downloaded the latest and greatest a few days ago. Extracted it into my c:\eclipse directory and then I installed the WTP full version because I wanted the context auto completion smart xml editing. It was not working so I installed WTP over the hibernate plug in. It did not help.. Max, this plug-in and WTP are okay with each other right? Manual say that they are so I am thinking that they are.

So next thing I used the Hibernate Plug in to create the hibernate.cfg.xml file and that sees to have worked pretty well. So I double click that file and I get a warning “This project is not a MyEclipse Hibernate Project. Assuming Hinberate 3 capabilities for the configuration editor”. I then click okay, because that is my only choice and it brings up a screen labeled “Hibernate Configuration” with several panes “Database Connection Details”, “Properties”, and “Mappings”..

So this is not yours.. Is that what we are saying.. I am fine with that, I just want to make sure I get what you are saying.. This explains the crazy behavior... Oh Max, if youa re right then this is great..

Max. I have done a bunch of work in hibernate and I want the rest of the company to use it but they are not going to go through the efforts that I did so that is why this tool is so important to us (ME). I really need a decent tool (and this looks t be more than a decent tool, if I can get it working) that will allow our guys to play with HQL and see the database entity stuff. I will build the mapping files and POJO by hand I don’t care.

This presentation is next Tuesday. Look help me get this tool working and I will either cut you a check or give you a bunch of points. I don’t care which. It is better to part with some money, than my job.. I will be happy to cut you a check, I am looking forward to it, or the points. Just work with me on this. I am making this commitment in front of the WHOLE WORLD, well at least the Hibernate part of the world. I will not break my word. I am serious. How does 50 bucks sound. You choose.

I have been talking up Hibernate for the last three months and “finally” the company is going to use it on one of our products.. I have gone through hell to get this far.. I can not loose now.. I need to get this tool working so that we can start converting between 2500 and 3000 SQL statements into hibernate HQL. They do not know HQL and are not all that excited about taking the time to learn it.. Change to them is BAD. We are a startup and time is not something we have a lot of. Without some easy way to do doing this HQL thing we will fail and I will probably get fired..

My plugin directory goes for pages.. I am going to reinstall everything in the event that you are right.. I am betting that you are indeed right.. I will let you know what happens..

And Max, thanks man.. it took two years to find this job and it will take a few days to loose it. I will be working on this effort all weekend as much as I can. Ph man.. I hope that you are right.. Oh tha twould make me SO HAPPY !!.. I will be jumping up and down.. Oh man. if I can just get this tool working.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 30, 2006 11:20 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
ok - you need to clean/fix some things ;)

1) Hibernate Tools works perfectly fine with WTP 1.0.x

2) Hibernate Tools does not try and wrap you into a safe house, it simply uses standard hibernate configuration to do its thing (thus it uses hibernate.cfg.xml and for that to work resources need to be on the classpath)

3) You seem to have MyEclipse installed (which is btw. not compatible with WTP 1.0.x AND ships with an old and modified version of hibernate tools which does not contain the query facilities.

4) If you want query facilities and the latest MyEclipse you will need to run it in two different eclipses - and no, not much I can do about it since it was MyEclipse that decided to change our stuff instead of using our stuff ;) (hopefully this will change in the near feature in upcoming myeclipse releases)

5) the hbiernate.cfg.xml editor you are seeing is myeclipse editor (we have one similar in cvs history, but did not include it because it were not good enough yet)

6) Remember that the console configuration has *additional* mapping files you don't need to mess with in normal sense + putting the right things in the classpath in the console configuration is eseential. The rights things are jdbc drivers and classpath needed to load your classes and mapping files. e.g. you /bin directory in default eclipse. Do not put hibernate jars in here since they are already configured here.

Good luck ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 30, 2006 1:15 pm 
Beginner
Beginner

Joined: Thu Feb 23, 2006 11:22 am
Posts: 30
MAN I blew away myEcipse and Eclipse. I then installed Eclipse-sdk-3.1.2-win32.zip.. Then I use the updater to find anything new. Nothing was found. So I then installed using the install manager (which is really cool) WTP from http://Download.eclipse.org/webtools/updates and that worked great.. So I rebooted Eclipse and my entire machine (can you tell that I am desperate!!) and installed the HibernateTools3.1-beta4..

WOW.. Everything just works.. Man this is so awesome. What a tool.. Man, you be a dam good software guy.. dam good..

Anyhow I am so happy.

I still can not seem to get the HQL thing working.. Sorry got so excited that I started trying it before I read the manual.. Hey I have been sweating for two days trying like hell to get this tools working so that I could issue my first HQL query. So ….

Please man.. If you can..

I have a mapped object called ContentData. I can see it inside of my root.hibernate package.. It is inside of my hibernate.cfg.xml file and I know that it all got constructed correctly.. So I go into the HQL window and I type “from ContentData” and I hit the green arrow and I get;
ContentData (wrong name:hibernate/ContentData)
Unhandled event loop exception
Please please can you tell me why.. Oh man if I could see one HQL work then this would have all been worth it.. Just one.. I will call my boss over and show him and WOW.. Also I do not seem to have anything inside the hibernate entity manager even through I can see my database in the Hibernate Configuration Perspective.. But I can handel that for now.. HQL is the key.. HQL HQL.. Yeah yeah..

Oh wait.. I did not map the XML file in the perspective that is it. Oh man this is great..

Oh no.. I added them and now I can not do a refresh.. I am dead.. BAD DOGGIE..
Error while fetching children
Reason:
Org.hibernate.MappingException: Resource: hibernate/PbmConent.hbm.xml not found

But it is there… Oh no.. Undoing the mapping files from the create Hibernate Console Configuration does not help… Oh no.. Put the keyboard down and move away from the computer….. it made another hibernate.cfg.xml file.. I deleted that extra one and no go.. oh no..

Put the keyboard down and move away from the computer…..

Bad Doggie.. can you help.. ha ha ha.. I am actually having fun.. but there is a seriouse side to this.. my job..


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 30, 2006 1:28 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
dude you are frantic.

if you have a layout like this:

Code:
src/
hibernate/
   ContentData.java
   ContentData.hbm.xml
bin/ (the build directory)
hibernate/
   ContentData.class
   ContentData.hbm.xml


then everytthing will work fine if if bin/ is in the console configuration path.

Why ? Because bin/ is the root for hibernate/ContentData.hbm.xml and hibernate.ContentData

/max

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 30, 2006 1:31 pm 
Beginner
Beginner

Joined: Thu Feb 23, 2006 11:22 am
Posts: 30
OH look what happened.. This is the problem.... Oh.. classpath again.. rats.. hibernate/ that should not be there..


Code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>
        <property name="hibernate.cglib.use_reflection_optimizer">true</property>
        <property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
        <property name="hibernate.connection.password">corvette!94</property>
        <property name="hibernate.connection.url">jdbc:postgresql:test</property>
        <property name="hibernate.connection.username">postgres</property>
        <property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
   [b]     <mapping resource="hibernate/PbmContext.hbm.xml" />
        <mapping resource="hibernate/ContentData.hbm.xml" />
        <mapping resource="hibernate/ContentDetail.hbm.xml" />
        <mapping resource="hibernate/PbmInitiative.hbm.xml" />
        <mapping resource="hibernate/PbmInitiativeKpiObj.hbm.xml" />
        <mapping resource="hibernate/PbmUser.hbm.xml" />
        <mapping resource="hibernate/PbmUsrGroup.hbm.xml" />
        <mapping resource="hibernate/PbmViewGroup.hbm.xml" />[/b]
    </session-factory>
</hibernate-configuration>


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 30, 2006 1:37 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
hibernate/ is probably there because you told it too be when reverse engineered, correct ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 30, 2006 1:37 pm 
Beginner
Beginner

Joined: Thu Feb 23, 2006 11:22 am
Posts: 30
pulled out the hibernate/ and now I can see the object inside the configuration but as you probably know

Session Factory error:compent class not found: hibernate.bla

humm you got to be really careful with what is specified and classpath issues.. Confusion on this topic equals pain...


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 30, 2006 1:43 pm 
Beginner
Beginner

Joined: Thu Feb 23, 2006 11:22 am
Posts: 30
oh by the way.. good call I did tell it that in the reverse engining part.

I wanted to have my classes live inside of something like root.hibernate so for output dierectory I said root and checked Reverse engineer from JDBC Connection and then in Pakcage I said hibernate..

but that was all working until I went into Create Hibernate Console Configuration and under Mapping FIles selected Add and added them.. Then the refresh started to fail..

But the HQL was not able to find Content Data so.. Maybe I never had it working and just because it refreshed and did not fail I thoght that I was okay.

These setting are confusing to me.. Should I blow away everything and start from scratch.. You know create a new Eclipse project.. But I will just do the same thing again.. humm.. ??


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 30, 2006 1:46 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
dude, this is plain vanilla java concepts.

package name = something that is rooted in a src/classes directory.

If you classes have package hibernate; in the top they should be in a hibernate dirctory. And the root of that directory is a root of a classpath.

I don't understand what the problem is with that.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 30, 2006 2:56 pm 
Beginner
Beginner

Joined: Thu Feb 23, 2006 11:22 am
Posts: 30
okay.. I will re-org my stuff to match the post above.. The "dude you are frantic" one.. Ha ha. I am just having fun working on this..

I did not have it that way but more like your last post.. But let me set it up EXACTLY like the one you have above. I am sure this is the problem.. I had things a little different so let me clean this all up.

Back at you in about 30 some.. minutes not days..

thanks man.. We are really close I can feel it..

ray


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 30, 2006 4:01 pm 
Beginner
Beginner

Joined: Thu Feb 23, 2006 11:22 am
Posts: 30
no go.. I am sitting here with the director of R&D at the company.. Can I send you my project or can I set it up as a webex and can you look at this.. I will call you.. Whatever it takes.. Can this be done..

In return I will write up a detail solution of how WE (you) got this to work and email it to you so that you can post it and it will help someone else..

how does that sound.

ray
good dog.. but sad dog..


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 26 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.