[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-5235) MultipleHiLoPerTableGenerator infers catalogs and schemas where none should be inferred
Edward Rayl (JIRA)
noreply at atlassian.com
Wed Feb 2 14:43:05 EST 2011
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-5235?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=39800#action_39800 ]
Edward Rayl commented on HHH-5235:
----------------------------------
Actually there is a (ugly) work-around. I put the correct annotation in the entity for EclipseLink to use. Then for Hibernate, I created a hibernate-orm.xml and referenced it from the persistence.xml:
<mapping-file>META-INF/hibernate-orm.xml</mapping-file>
The interesting lines in the ORM file are:
<!-- Fix for Hibernate bug HHH-5235: table name is repeated as the schema name when using @TableGenerator.
Workaround: add schema name to the table name even though the schema name is specified in the META-INF/orm.xml.
This workaround is incompatible with EclipseLink, since it correctly uses the schema from orm.xml.
-->
<package>cc.pharmacy.entity</package>
<entity class="Drug">
<table-generator
name = "drugGen"
table = "PHARMACY.ID_SEQUENCES"
pk-column-name = "SEQUENCE_NAME"
value-column-name = "SEQUENCE_VALUE"
pk-column-value = "drugs"
allocation-size = "1"
initial-value = "500000"/>
</entity>
> MultipleHiLoPerTableGenerator infers catalogs and schemas where none should be inferred
> ---------------------------------------------------------------------------------------
>
> Key: HHH-5235
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5235
> Project: Hibernate Core
> Issue Type: Bug
> Components: core
> Affects Versions: 3.5.2
> Environment: Hibernate 3.5.2-Final, H2 database version 1.2.134
> Reporter: Laird Nelson
>
> I have a @TableGenerator annotation and an associated @GeneratedValue like this:
> @Entity(name = "PostalAddress")
> @TableGenerator(
> name = "PostalAddressEntityIDGenerator",
> table = "JPAGenerators",
> pkColumnName = "generatorName",
> pkColumnValue = "PostalAddressEntityIDGenerator",
> valueColumnName = "generatorValue",
> allocationSize = 1
> )
> public class PostalAddressEntity {
> @GeneratedValue(strategy = GenerationType.TABLE, generator = "PostalAddressEntityIDGenerator")
> @Id
> private long id;
> /* etc. */
> }
> At runtime, the following SQL shows up:
> select generatorValue from JPAGenerators.JPAGenerators.JPAGenerators where generatorName = 'PostalAddressEntityIDGenerator' for update
> Note the table name repeated three times as though it is both the catalog, the schema and the table name.
> It seems that the MultipleHiLoPerTableGenerator, when asked to build its SQL strings for various operations, is told that the schema, the catalog and the table name are all the same.
> I was expecting that the catalog would default to "", per the TableGenerator documentation, and that the schema would default to whatever was present in orm.xml's persistence-unit-defaults element.
> I can work around this by explicitly spelling out the schema name in my @TableGenerator annotation, but I don't want to put it there (can't, actually). I can also work around this in a JPA-compliant manner by defining my table generator in my orm.xml file, but I don't want to do that either.
--
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