[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2035) Generate hibernate.cfg file from used persisted entities only
Holger Haag (JIRA)
noreply at atlassian.com
Tue Aug 29 10:14:24 EDT 2006
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2035?page=comments#action_24210 ]
Holger Haag commented on HHH-2035:
----------------------------------
Hi,
thanks for your time.
1) Where are the code that actual add elements to the usedPersisters map ?
sorry, that was a mistake when I created the patch. I'll provide a new patch anyway.
2) Does it work with associations ? (e..g if A point to B and only A is used, B is still needed in your configuration)
the new patch should... The entities are now collected in AbstractEntityPersister, which seems to be a better place (the old patch used TwoPhaseLoad).
I've tried the following scenarios
- simple class mapping (1 class = 1 table)
- simple one-to-many (foreign key) relationship
- insert new objects
- search for existing objects
Not sure about other scenarios which I do not use though (e.g. many-to-many or collections).
3) Couldn't this be done via eventlisteners instead of mutating TwoPhaseLoad class?
I'll leave the answer up to you ;-) Since I'm not that familiar with the hibernate code, I've used a very simple approach. But I cannot help you on this issue very much.
I also haven't looked very much at performance or thread synchronization issues, since I assume that calls to java.util.HashMap are pretty fast and even if two threads add the same entity simultaneously, that shouldn't be a big issue.
Please note that the new patch now has a new class - org.hibernate.stat.PersistedEntities - which covers most of the required functions. The patch to the AbstractEntityPersister only contains one call to PersistedEntities. That should make it easier for you if you want to use a different approach, e.g. the above mentioned listeners.
> Generate hibernate.cfg file from used persisted entities only
> -------------------------------------------------------------
>
> Key: HHH-2035
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2035
> Project: Hibernate3
> Type: New Feature
> Components: core
> Environment: Hibernate 3.x + Hibernate annotations
> Reporter: Holger Haag
> Priority: Minor
> Attachments: TwoPhaseLoad-writeUsedPersisters.patch, hibernate-template.cfg.xml
>
>
> Original post from Hibernate forum: http://forum.hibernate.org/viewtopic.php?t=963888
> The patch allows to call a new method TwoPhaseLoad.writeUsedPersisters which will generate a complete hibernate.cfg configuration file containing only the entities which have been persisted so far.
> The rationale behind this is that for unit test cases it is often sufficient - and much faster - to initialize hibernate with only a subset of all persisted classes, but it is cumbersome to find out which subset is the smallest possible.
> Attached is a SVN patch for the latest SVN trunk and a sample template file.
> Feel free to modify/put it into the hibernate code in any way you want, I think it can increase productivity - startup times for my test cases have dropped by 10 seconds.
> Please note that this patch will only work if you use Hibernate annotations since the generated XML file only contains class, not column mappings.
--
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.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list