Updated DAO code generation as discussed over the email

Description

This should be a complete implementation of DAO generation according to the design we have discussed over the email. I've tested this on our project so the DAOs should be good to go, but of course a more diverse testing would be needed before releasing it to public. I'm open for recommendations and suggestions, so I see this as the first draft. Below is a list of files and comments. Contact me at kalinovsky@yahoo.com.

src/java/org/hibernate/tool/hbm2x
DAONewExporter.java This class is coded mainly to accept additional parameters such as dao package name and provide flexible
file naming that is used by Ant task. It would not be needed if I integrate my changes into GenericExporter.

src/templates/dao
crudDao.ftl template for regeneratable CRUD interface
crudDaoImpl.ftl template for regeneratable CRUD DAO implementation
dao.ftl template for customizable DAO interface that extends CRUD interface
daoImpl.ftl template for customizable DAO implementation that extends CRUD implementation

src/templates/dao/base
dao.ftl base interface for all DAOs
queryDao.ftl base interface for all read-only entities
crudDao.ftl base interface for all editable entities

src/templates/dao/base/hibernate
abstractDao.ftl base implementation of DAO using Hibernate
abstractQueryDao.ftl base implementation of DAO for read-only entities using Hibernate
abstractCrudDao.ftl base implementation of DAO for editable entities using Hibernate

src/testsupport
codegen.properties Test configuration to see DAO generation in action
codegen-build.xml Test build file that generates DAOs for Author and Article and compiles generated code

Environment

I have tested the patch on the latest version of Hibernate Tools I got from SVN 2 weeks ago.

Attachments

1
  • 20 Aug 2006, 08:32 PM

Activity

Show:

Koen Aers December 5, 2024 at 1:33 PM

I am closing this issue as the last relevant update was in 2007. Please feel free to reopen if you feel that this is still relevant.

MH November 17, 2007 at 6:21 AM

This is an old thread - and has obviously been dismissed by some folk... But I gotta say - as soon as a pojo has annotations, it ain't a pojo no more. It's maybe a... 'pojowmd' (with meta data). When you add metadata to an object... It's not - by definition - a plain old java object any more.

Christian Bauer November 7, 2006 at 3:06 AM

Please take this to the forum. We don't need any discussion about the proprietary Spring application server here.

Emmanuel Bernard November 7, 2006 at 2:54 AM

Check the code, Hibernate Annotations has no EJB 3.0 bells and whistles whatever that means
It certainly do not depends on an App server (for that matter the EJB 3.0 Persistence spec aka JPA does not either).

As for the EJB 3.0 decorator, are you referring to the annotations? @Entity and so on?
So what is best, having an annotation @org.hibernate.annotations.Table to describe a table, or having a standard annotation @javax.persistence.Table?
There is no difference, technically, except that you are closer to the standard. Any drawback? No.

People completely misunderstand EJB 3.0 because they thing that EJB 3.0 == EJB 2.x, this is not true, read the spec. For that matter, JBoss has an EJB 3.0 container which is "as lightweight" as Spring Framework, yes it runs in a junit test. yes it runs in tomcat. Some competitor might have a heavyweight implementation but that is clearly not inherent to the specification.

FTR, I do believe that EJB 3.0 (the container) combines with Hibernate (and JPA) even better than Spring.

Check the docs and tutorials slightly smiling face

Christian Bauer November 7, 2006 at 2:51 AM

Entity classes as defined by the EJB 3.0 specification are plain Java classes. If you need someone to explain this, please use http://forum.hibernate.org/

Won't Fix

Details

Assignee

Reporter

Patch Reminder (view)

Contributions and patches should be using the GitHub Fork + Pull model

Patch Reminder (edit)

Contributions and patches should be using the GitHub [Fork + Pull model|href="https://help.github.com/articles/using-pull-requests]

Participants

Alex Kalinovsky
Biju Rajan
Christian Bauer
Emmanuel Bernard
Geert Poels
Koen Aers
Max Rydahl Andersen
MH

Original estimate

Time tracking

No time logged24h remaining

Components

Fix versions

Affects versions

Priority

Created August 20, 2006 at 8:32 PM
Updated December 5, 2024 at 1:33 PM
Resolved December 5, 2024 at 1:33 PM