[hibernate-issues] [Hibernate-JIRA] Commented: (HBX-910) hbm2ddl doesn't create identity column with custom identifier generator
Guenther Enthaler (JIRA)
noreply at atlassian.com
Thu Jul 24 00:51:12 EDT 2008
[ http://opensource.atlassian.com/projects/hibernate/browse/HBX-910?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_30720 ]
Guenther Enthaler commented on HBX-910:
---------------------------------------
I agree, unless there's an easy way to use a custom variant of SimpleValue for my identity properties.
> hbm2ddl doesn't create identity column with custom identifier generator
> -----------------------------------------------------------------------
>
> Key: HBX-910
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-910
> Project: Hibernate Tools
> Issue Type: Bug
> Environment: hibernate 3.2.1 hsqldb 8.0.1
> Reporter: Luca Dall'Olio
> Priority: Minor
>
> When defining a custom identifiergenerator which implements org.hibernate.id.PostInsertIdentifierGenerator ,
> hbm2ddl doesn't define the primary key column as identity (i.e. hibernate.hbm2ddl.auto=create)
> By looking at the source code, the hbm2dll depends on org.hibernate.mapping.SimpleValue.isIdentityColumn() function, which in turn has a direct dependency on IdentityGenerator.class :
> public boolean isIdentityColumn(Dialect dialect) {
> return IdentifierGeneratorFactory.getIdentifierGeneratorClass(identifierGeneratorStrategy, dialect)
> .equals(IdentityGenerator.class);
> }
> in my opinion, it should depend instead on the PostInsertIdentifierGenerator interface :
> public boolean isIdentityColumn(Dialect dialect) {
> return IdentifierGeneratorFactory.getIdentifierGeneratorClass(identifierGeneratorStrategy, dialect)
> .isInstance(PostInsertIdentifierGenerator.class);
> }
> Here is an example of a custom IdentityGenerator which can reproduce this problem :
> package sample;
> ...
> public class CustomIdentifierGenerator implements IdentifierGenerator, PostInsertIdentifierGenerator {
> private static IdentityGenerator hibernateGeneratorDelegate = null;
> public Serializable generate(SessionImplementor session, Object object)
> throws HibernateException {
> return hibernateGeneratorDelegate.generate(session, object);
> }
> public InsertGeneratedIdentifierDelegate getInsertGeneratedIdentifierDelegate(
> PostInsertIdentityPersister persister, Dialect dialect,
> boolean isUseGet) throws HibernateException {
> return hibernateGeneratorDelegate.getInsertGeneratedIdentifierDelegate(persister, dialect, isUseGet);
> }
> }
> Here an example mapping fragment :
> <id name="id" type="long" column="DMM_ID">
> <generator
> class="sample.CustomIdentifierGenerator " />
> </id>
--
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