[
http://opensource.atlassian.com/projects/hibernate/browse/HBX-733?page=co...
]
Alex Kalinovsky commented on HBX-733:
-------------------------------------
Max,
I am totally open for comments and I can make adjustments to the code. Removing is always
easier then adding:-)
been looking into this today and got some reservations for parts of
the
code generated:
e.g.
why is isInitialized() needed in the dao public interface and why are you
referring to net.sf.cglib.transform.impl.InterceptFieldCallback and other
implementation details of hibernate ?
In my project we were using lazy properties. Initially the objects were loaded without
the lazy properties. Later on, if the user wanted to see the details, those properties had
to be initialized. The implementation was somewhat hairy and I think now Hibernate has a
"fetch" keyword for eagerly initializing the lazy properties so I can take
initialize() out. There's also an issue of loading lazy associations for a given
instance. From my exeprience, Hibernate can only eagerly load up to 1 lazy collection,
right? So if you have object A that is accociated with B, C and D. You can not run a query
SELECT A LEFT JOIN FETCH B LEFT JOIN FETCH C LEFT JOIN FETCH D. So initialize() is handy
for that.
You can argue that it should not be in the public interface and I have no problems
removing it completely. Just let me know.
what is the NAME constant in dao.ftl usable for ? It is exactly the
same as
someclass.class.getName() so why have a codegenerated constant for it ?
We use the constant to refer to the beans in generated Spring contexts.
someclass.class.getName() is more combersome then someclass.NAME and doesn't provide
as much flexibility. But I am not sure that it should be in a generic Hibernate DAO so if
you want I can take it out.
If you recall, what I have is a complete code generator that generates HBM files, model
objects, DAOs, services, Spring context that uses dependency injection to wire DAO,
Service and Model class. It now has generation of Struts actions, forms, message and
validation files. I don't know if you'd want to see the rest of the stuff in
Hibernate tools but the NAME constant is in the application.
Updated DAO code generation as discussed over the email
-------------------------------------------------------
Key: HBX-733
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HBX-733
Project: Hibernate Tools
Type: Patch
Components: hbm2java, ant
Versions: 3.1alpha5
Environment: I have tested the patch on the latest version of Hibernate Tools I got from
SVN 2 weeks ago.
Reporter: Alex Kalinovsky
Attachments: dao_generation.patch
Original Estimate: 3 days
Remaining: 3 days
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(a)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
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira