[Hibernate-JIRA] Created: (HHH-2598) Mapping a collection of entities from two different classes with the same collection name results in duplicate backref property exception if collection keys are not null
by Guido Scalise (JIRA)
Mapping a collection of entities from two different classes with the same collection name results in duplicate backref property exception if collection keys are not null
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Key: HHH-2598
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2598
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.3, 3.2.2, 3.2.1
Environment: Proven on Hibernate 3.2.2 and 3.2.3, PostgreSQL 8.2.3, WindowsXP, Java 1.5
Reporter: Guido Scalise
Attachments: backref.patch, Hibernate-bug.zip
Mapping a child entity collection from two different parent entities results in duplicate backref property exception when configuring the session factory if the collection keys are marked not null and the collection names are the same in both parents.
Log is:
(cfg.Environment 509 ) Hibernate 3.2.3
(cfg.Environment 542 ) hibernate.properties not found
(cfg.Environment 676 ) Bytecode provider name : cglib
(cfg.Environment 593 ) using JDK 1.4 java.sql.Timestamp handling
(cfg.Configuration 1426) configuring from resource: /hibernate.cfg.xml
(cfg.Configuration 1403) Configuration resource: /hibernate.cfg.xml
(cfg.Configuration 553 ) Reading mappings from resource : com/bbsw/tests/ParentA.hbm.xml
(cfg.HbmBinder 300 ) Mapping class: com.bbsw.tests.ParentA -> PARENT_A
(cfg.Configuration 553 ) Reading mappings from resource : com/bbsw/tests/ParentB.hbm.xml
(cfg.HbmBinder 300 ) Mapping class: com.bbsw.tests.ParentB -> PARENT_B
(cfg.Configuration 553 ) Reading mappings from resource : com/bbsw/tests/Child.hbm.xml
(cfg.HbmBinder 300 ) Mapping class: com.bbsw.tests.Child -> CHILD
(cfg.Configuration 1541) Configured SessionFactory: null
(cfg.HbmBinder 2375) Mapping collection: com.bbsw.tests.ParentA.children -> CHILD
(cfg.HbmBinder 2375) Mapping collection: com.bbsw.tests.ParentB.children -> CHILD
Exception in thread "main" org.hibernate.MappingException: Duplicate property mapping of _childrenBackref found in com.bbsw.tests.Child
at org.hibernate.mapping.PersistentClass.checkPropertyDuplication(PersistentClass.java:459)
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:449)
at org.hibernate.mapping.RootClass.validate(RootClass.java:192)
at org.hibernate.cfg.Configuration.validate(Configuration.java:1102)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1287)
at HBTest.main(HBTest.java:17)
The problem seems to be originated during the second Collection binding pass in org.hibernate.cfg.HbmBinder, as the Backrefs and IndexBackrefs names are created like this:
(Excerpts from HbmBinder.java r10921 2006-12-05 14:39:12Z steve.ebersole(a)jboss.com, contained in the Hibernate 3.2.3.ga source)
line 2242: IndexBackref ib = new IndexBackref();
line 2243: ib.setName( '_' + node.attributeValue( "name" ) + "IndexBackref" );
and
line 2478: Backref prop = new Backref();
line 2479: prop.setName( '_' + node.attributeValue( "name" ) + "Backref" );
in both cases the node name value is the collection name. So for every collection that points to a child, Hibernate creates a backref property without considering the posibility of more than one entity declaring the same collection name.
I've patched the code to add the collection owner's entity name to the property name, and it worked without problems.
I'm attaching:
* ParentA, ParentB and Child classes
* Mappings for ParentA, ParentB and Child
* hbm.xml file
* Main test case. (HBTest.java)
* Proposed patch in unified diff format.
--
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
18 years, 1 month
[Hibernate-JIRA] Created: (HHH-2593) Keyword UNION is prefixed with "this_." in filter conditions
by Frederic Leitenberger (JIRA)
Keyword UNION is prefixed with "this_." in filter conditions
------------------------------------------------------------
Key: HHH-2593
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2593
Project: Hibernate3
Issue Type: Bug
Components: query-hql, query-sql
Affects Versions: 3.2.1
Environment: Oracle 10g: org.hibernate.dialect.OracleDialect
Suse Linux
Hibernate: 3.2.1.ga
Hibernate Annotations: 3.2.1.GA
Reporter: Frederic Leitenberger
Priority: Trivial
I need to use a UNION-Subquery in a Filter condition unless HHH-298 is solved.
But anyway, when using the keyword "union" in the Filter condition it is prefixed with "this_.".
For instance, this ...
@Filter(name = "resellerFilter", condition = "(select cu.resellerId from Customer cu, GeoNumber gn where (cu.id = gn.customerId and gn.id = this_.geoNumberId) UNION select cu.resellerId from Customer cu where cu.detemeTemplateId = this_.id) in (null, :resellerIds)")
... produces this ...
select
...
from
DeTeMe this_
where
(
select
cu.resellerId
from
Customer cu,
GeoNumber gn
where
(
cu.id = gn.customerId
and gn.id = this_.geoNumberId
) this_.UNION select
cu.resellerId
from
Customer cu
where
cu.detemeTemplateId = this_.id
) in (
null, ?
)
and this_.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....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
18 years, 1 month
[Hibernate-JIRA] Created: (HHH-2297) invalid id type error message doesn't report which entity
by Kelly Campbell (JIRA)
invalid id type error message doesn't report which entity
---------------------------------------------------------
Key: HHH-2297
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2297
Project: Hibernate3
Type: Patch
Components: metamodel
Versions: 3.2.0.ga
Reporter: Kelly Campbell
Priority: Minor
Attachments: hibernate-id-type.patch
The error message given here makes it very hard to determine what entity has the problem.
Simple patch is attached.
java.lang.UnsupportedOperationException: not a valid id type
at org.hibernate.type.CharacterType.getDefaultValue(CharacterType.java:20)
at org.hibernate.engine.UnsavedValueFactory.getUnsavedIdentifierValue(UnsavedValueFactory.java:48)
at org.hibernate.tuple.PropertyFactory.buildIdentifierProperty(PropertyFactory.java:44)
at org.hibernate.tuple.EntityMetamodel.(EntityMetamodel.java:114)
at org.hibernate.persister.entity.AbstractEntityPersister.(AbstractEntityPersister.java:418)
at org.hibernate.persister.entity.SingleTableEntityPersister.(SingleTableEntityPersister.java:108)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
at org.hibernate.impl.SessionFactoryImpl.(SessionFactoryImpl.java:223)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1213)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:631)
at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:760)
at org.hibernate.ejb.Ejb3Configuration.createFactory(Ejb3Configuration.java:151)
at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:205)
--
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
18 years, 1 month
[Hibernate-JIRA] Created: (HHH-2261) Setting hibernate.hbm2ddl.auto=validate causes problems on mySQL with numeric fields
by Christian Sprajc (JIRA)
Setting hibernate.hbm2ddl.auto=validate causes problems on mySQL with numeric fields
------------------------------------------------------------------------------------
Key: HHH-2261
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2261
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.2.1
Reporter: Christian Sprajc
Hello,
We got a Problem when using the following setup:
1) JBoss 4.0.4A with Hibernate 3.2.0 / mySQl 4.x AND 5.x
2) Set hibernate.hbm2ddl.auto=validate
3) Using a usertype which uses the SQL type: Types.NUMERIC
When deploying our application I got the following error:
12:43:21,985 INFO [TableMetadata] columns: [paymenttype, amount, oid, remarks, currency, ae_date]
12:43:21,985 WARN [ServiceController] Problem starting service persistence.units:jar=com.riege.pogo_0.1.4.jar,unitName=PogoEntityManager
org.hibernate.HibernateException: Wrong column type: amount, expected: numeric(19,2)
at org.hibernate.mapping.Table.validateColumns(Table.java:251)
at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:1002)
The Problem is:
1) When hibernate creates (e.g. hibernate.hbm2ddl.auto=update) through the columns in the mySQL database it creates it as "numeric(x,y)" field.
2) mySQL always converts "numeric(x,y)" to "decimal(x,y)". The metadata returns "decimal(x,y)"
3) When deploying with "hibernate.hbm2ddl.auto=validate" to error above is thrown. The problem is that hibernate expects a "numeric(x,y)" type but mysql returns a "decimal(x,y)"
A workaround I'm now using is a fixed mySQL dialect which correctly handles Types.DECIMAL / "decimal(x,y)":
public class FixedMySQLDialect extends org.hibernate.dialect.MySQLDialect {
public FixedMySQLDialect() {
super();
registerColumnType(Types.NUMERIC, "decimal(19, $l)");
registerColumnType(Types.DECIMAL, "decimal(19, $l)");
}
}
--
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
18 years, 1 month
[Hibernate-JIRA] Created: (HHH-2582) foncusion of DECIMAL and NUMERIC column types in MySQL5
by Gerald Loeffler (JIRA)
foncusion of DECIMAL and NUMERIC column types in MySQL5
-------------------------------------------------------
Key: HHH-2582
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2582
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.0.ga
Environment: MySQL 5.0.27 InnoDB on windows
Reporter: Gerald Loeffler
when doing schema validation with
<property name="dialect">
org.hibernate.dialect.MySQL5InnoDBDialect</property>
<property name="hbm2ddl.auto">validate</property>
against a table with a DECIMAL/NUMERIC columns, the hibernate schema validator always reports a column type mismatch, saying that it expected "NUMERIC".
this can be explained as follows:
1. MySQL always reports columns created as NUMERIC or DECIMAL as DECIMAL. i.e.,
CREATE TABLE `T` (
`d` decimal(10,0) NULL,
`n` numeric(10,0) NULL
)
will create a table where both columns d and n are of dataype DECIMAL.
2. the hibernate MySQL5InnoDBDialect ultimately inherits from MySQLDialect and this registers the following column type:
registerColumnType(2, "numeric($p,$s)");
which means that when doing schema validation against a column of type DECIMAL hibernate will report a type mismatch.
indeed, if one creates a new hibernate dialect which is identical to MySQL5InnoDBDialect/MySQLDialect in all respects apart from registering the following column typ
registerColumnType(2, "decimal($p,$s)");
then the aforementioned schema validation error is not reported, i.e., schema validation succeeds as expected.
--
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
18 years, 1 month