Thread: Does anyone use postgreSQL(windows version)+Hibernate with middlegen?

Does anyone use postgreSQL(windows version)+Hibernate with middlegen?

From
rolandpeng
Date:
Hello ,

Does anyone use PostgreSQL(windows version)+Hibernate with middlegen to
generate *.hbm.xml?
I used to use OracleXE as my application database. For some reason,I will
try to use PostgreSQL.
I have install PostgreSQL 8.3.7 windows version.
But I found middlegen aren't able to generate *.hbm.xml for me via
PostgreSQL.(OracleXE is okay.)

How do you resolve this problem? or If you use postgreSQL+Hibernate3,how do
you maintain your *.hbm.xml and entities?

Any comments or advices will be welcome.Thank you.

Roland.


--
View this message in context:
http://www.nabble.com/Does-anyone-use-postgreSQL%28windows-version%29%2BHibernate-with-middlegen--tp23089668p23089668.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.


Re: Does anyone use postgreSQL(windows version)+Hibernate with middlegen?

From
Craig Ringer
Date:
rolandpeng wrote:

> How do you resolve this problem? or If you use postgreSQL+Hibernate3,how do
> you maintain your *.hbm.xml and entities?

I use Hibernate 3 with PostgreSQL via JPA (Hibernate EntityManager). I
maintain my entity definitions by hand.

I find generated solutions to generally be unsatisfactory. They don't
tend to preserve my customizations for eager/lazy fetching,
updatability, etc, nor my entity initialization changes. They don't
generally handle domain types all that well, and they don't always pick
the best type to map for a PostgreSQL field.

They tend to clobber my documentation, too.

They have a lot of trouble with things like NOT NULL fields that are set
by a server-side trigger, so the client application *MUST* *NOT* set
them on INSERT even though they're NOT NULL in the schema. Yet I have
one problem that I have only been able to solve in exactly this way.
It's easy to handle in a custom binding (set nullable=true,
updatable=false) but binding generators just don't and can't have that
kind of knowledge.

Bindings generators are useful as a starting point, but unless your
schema is really rather simple I'm not convinced about their long-term
utility.

--
Craig Ringer

Re: Does anyone use postgreSQL(windows version)+Hibernate with middlegen?

From
rolandpeng
Date:
Yes,I'm totally agree about this comments.
But as you're mentioned,I'd like to build all the hbm.xml at first run.
I have built more than 40 tables with complicated relations among those.
So if middlegen could help me to complete the template work at first
generation would be very convenience.

Today I have downloaded the middlegen-2.2dev from CVS and use ant
successfully rebuild.
Here I'll try to keep track on middlegen with PostqreSQL.
But if I still can't make it successfully generation,I think I'll maintain
all the hibernate resource manually.

Thanks again.Any comments or advice will be very welcome.


Craig Ringer wrote:
>
> Bindings generators are useful as a starting point, but unless your
> schema is really rather simple I'm not convinced about their long-term
> utility.
>

--
View this message in context:
http://www.nabble.com/Does-anyone-use-postgreSQL%28windows-version%29%2BHibernate-with-middlegen--tp23089668p23090476.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.


Re: Does anyone use postgreSQL(windows version)+Hibernate with middlegen?

From
Craig Ringer
Date:
rolandpeng wrote:
> Yes,I'm totally agree about this comments.
> But as you're mentioned,I'd like to build all the hbm.xml at first run.
> I have built more than 40 tables with complicated relations among those.
> So if middlegen could help me to complete the template work at first
> generation would be very convenience.

NetBeans does fairly decent schema generation, at least for JPA. I'm not
too sure whether it supports XML-based schema definitions too.

Personally, I look at the XML-based hibernate stuff and shudder. JPA
isn't exactly beautiful, but it's fairly maintainable and kind of clean.
If you're building a new project, have you considered using JPA and
Hibernate EntityManager? You can always drop back down to the underlying
Hibernate APIs when you need to (for example: setting parent/child
autodelete relationships, which aren't defined in JPA 1 only in the
yet-to-be-availible JPA2) and most of the time EntityManager is very
nice to work with. You still use HQL, or native SQL queries as/when you
prefer.

--
Craig Ringer

Re: Does anyone use postgreSQL(windows version)+Hibernate with middlegen?

From
rolandpeng
Date:
I have found the correct combinations to solve this problem.
Let me brief what I have done,and the way is simple.

1.download latest middlegen from CVS
(:pserver:anonymous@middlegen.cvs.sourceforge.net:/cvsroot/middlegen)

2.build the source with ant,then I have middlegen2.2-dev bundles jar files.
(http://boss.bekk.no/boss/middlegen/install.html)

3.download latest postgreSQL driver (I use postgresql-8.3-604.jdbc3.jar)
4.modify relative parameters in middlegen ant build.xml

then all the generation works as what I want.

--
View this message in context:
http://www.nabble.com/Does-anyone-use-postgreSQL%28windows-version%29%2BHibernate-with-middlegen--tp23089668p23093725.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.