Generating Entity Classes from Database Model

33 views
Skip to first unread message

Humberto Marchezi

unread,
Nov 20, 2008, 7:37:59 AM11/20/08
to nhu...@googlegroups.com
Hello,

Does anyone know something about a utility program that lets me to generate Entity Models (POJO classes) (including *.hbm.xml mappings)
from a SQL scheme ?

I guess there was an utility called sql2hbm or something like this ... but i can´t find it.

Thanks a lot.

--
Humberto C Marchezi
---------------------------------------------------------
Master in Electrical Engineering - Automation
Software Consultant and Developer
at the Town Hall of Vitória

Stefan Sedich

unread,
Nov 20, 2008, 7:42:52 AM11/20/08
to nhu...@googlegroups.com
Hello,

I would look at MyGeneration and use a template to do this for you, I
would use the NHibernate lujan99 template for MyGeneration.


But I guess I would then reccomend that you hand roll your POCO and
mapping files :) will save you in the long run.



Cheers
Stefan
--
Stefan Sedich
Software Developer
http://weblogs.asp.net/stefansedich

Fabio Maulo

unread,
Nov 20, 2008, 7:46:31 AM11/20/08
to nhu...@googlegroups.com
To have your entities representing your Tables instead your domain you can use:
MyGeneration
CodeSmith
GenWise
For something little better
VisualParadigmn
AjGenesis
and perhaps there are something more.... but....
The best tool is your mind and your hands trough your keboard


2008/11/20 Humberto Marchezi <hcmar...@gmail.com>



--
Fabio Maulo

Stefan Sedich

unread,
Nov 20, 2008, 7:49:13 AM11/20/08
to nhu...@googlegroups.com
"The best tool is your mind and your hands trough your keboard"


Very well put :)

Fabio Maulo

unread,
Nov 20, 2008, 7:53:24 AM11/20/08
to nhu...@googlegroups.com
2008/11/20 Stefan Sedich <stefan...@gmail.com>


"The best tool is your mind and your hands trough your keboard"

Very well put :)

Yes Stefan...
And when we will define something to map a class without write absolutely nothing more than the class we can use NH as a OODB.

;) 

--
Fabio Maulo

Humberto Marchezi

unread,
Nov 20, 2008, 8:00:57 AM11/20/08
to nhu...@googlegroups.com
You all are definetely right. You have been using NHibernate only by manually implementing the POCO and XML mappings. 

The reason I am asking this is that I want to present NHibernate as an alternative to Linq-to-SQL to a group of developers here. The auto-generating capability of Linq-to-SQL doesn´t seem to be very useful in the long term since it requires the developers to work in a table-oriented-way however this feature is also very powerful and appealing to new developers.

In the other hand If I demonstrate I can generate classes and hbm mappings from an SQL scheme than I can reduce the importance of Linq-to-SQL. At the same time, it can be useful for small and/or not integrated software projects in the department I work for.

Additionally I have another question: Where can I find NHibernate-to-Linq ?
I was in Ayende´s site but he said it was moved to NHibernate.Contrib but I couldn´t find this project.
Can anyone tell me where to download it ?

thanks

Humberto Marchezi

unread,
Nov 20, 2008, 8:02:33 AM11/20/08
to nhu...@googlegroups.com
Correction: 'We have been using NHibernate only by manually implementing the POCO and XML mappings.'

Fabio Maulo

unread,
Nov 20, 2008, 8:03:47 AM11/20/08
to nhu...@googlegroups.com
This is the first link googling "NHibernate Contrib"



--
Fabio Maulo

Fabio Maulo

unread,
Nov 20, 2008, 8:09:13 AM11/20/08
to nhu...@googlegroups.com
2008/11/20 Humberto Marchezi <hcmar...@gmail.com>

You all are definetely right. You have been using NHibernate only by manually implementing the POCO and XML mappings. 

The reason I am asking this is that I want to present NHibernate as an alternative to Linq-to-SQL to a group of developers here. The auto-generating capability of Linq-to-SQL doesn´t seem to be very useful in the long term since it requires the developers to work in a table-oriented-way however this feature is also very powerful and appealing to new developers.

--
Fabio Maulo

Stefan Sedich

unread,
Nov 20, 2008, 8:10:57 AM11/20/08
to nhu...@googlegroups.com
Or you can use Linq to EF *shudders*

Eric Kepes

unread,
Nov 20, 2008, 12:01:33 PM11/20/08
to nhu...@googlegroups.com
I think opening the can of worms by telling other developers that they can generate their classes/mappings is extremely dangerous. We had all kinds of issues, both with performance and with things just plain not working, and it is completely attributable to building our mappings and classes with a generator.
 
Now, after having advanced up the learning curve a lot more (i.e. we know enough to be dangerous now), we keep seeing things we greatly regret and end up having to fix, often at the cost of making breaking changes across the whole app, which definitely pisses people off, and wouldn't even be sanely possible without Resharper.
 
Just 2c from someone who's touched the hot stove a few times...
-e

Reply all
Reply to author
Forward
0 new messages