[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
17 years, 3 months
[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
17 years, 3 months
[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
17 years, 3 months
[Hibernate-JIRA] Created: (HHH-2113) Incorrect join ordering with filters and JOINED inheritance
by Barney Boisvert (JIRA)
Incorrect join ordering with filters and JOINED inheritance
-----------------------------------------------------------
Key: HHH-2113
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2113
Project: Hibernate3
Type: Bug
Versions: 3.2.0.cr4
Environment: Hibernate 3.2.0 CR4, MySQL 4.1.20
Reporter: Barney Boisvert
I've a TextBlock object that extends AbstractContentObject (and has myriad other associations illustrated here, but irrelevant) and when doing a polymorphic query for all AbstractContentObjects Hibernate runs this SQL (note the line with the trailing asterisks):
select
textblockv0_.id as id21_5_,
textblockv0_.createTimestamp as createTi2_21_5_,
textblockv0_.hibernateVersionId as hibernat3_21_5_,
textblockv0_.lastUpdateTimestamp as lastUpda4_21_5_,
textblockv0_.lastVersionNumber as lastVers5_21_5_,
textblockv0_.activeVersionId as activeVe6_21_5_,
textblockv1_.id as id20_0_,
textblockv1_.createTimestamp as createTi2_20_0_,
textblockv1_.hibernateVersionId as hibernat3_20_0_,
textblockv1_.lastUpdateTimestamp as lastUpda4_20_0_,
textblockv1_.versionNumber as versionN5_20_0_,
textblockv1_.frozen as frozen20_0_,
textblockv1_.commitMessage as commitMe7_20_0_,
textblockv1_.title as title20_0_,
textblockv1_.summary as summary20_0_,
textblockv1_.text as text20_0_,
textblockv1_.versionHistoryId as version11_20_0_,
textblockv2_.id as id21_1_,
textblockv2_.createTimestamp as createTi2_21_1_,
textblockv2_.hibernateVersionId as hibernat3_21_1_,
textblockv2_.lastUpdateTimestamp as lastUpda4_21_1_,
textblockv2_.lastVersionNumber as lastVers5_21_1_,
textblockv2_.activeVersionId as activeVe6_21_1_,
textblock3_.id as id18_2_,
textblock3_1_.createTimestamp as createTi2_18_2_,
textblock3_1_.hibernateVersionId as hibernat3_18_2_,
textblock3_1_.siteId as siteId18_2_,
textblock3_1_.orderCol as orderCol18_2_,
textblock3_1_.folderId as folderId18_2_,
textblock3_.versionHistoryId as versionH2_19_2_,
site4_.id as id1_3_,
site4_.createTimestamp as createTi2_1_3_,
site4_.hibernateVersionId as hibernat3_1_3_,
site4_.lastUpdateTimestamp as lastUpda4_1_3_,
site4_.name as name1_3_,
site4_.parentId as parentId1_3_,
site4_.timeZone as timeZone1_3_,
site4_.familyId as familyId1_3_,
site4_.externalSiteAccessControl as external7_1_3_,
site4_.canonicalDomainId as canonic10_1_3_,
folder5_.id as id17_4_,
folder5_.createTimestamp as createTi2_17_4_,
folder5_.hibernateVersionId as hibernat3_17_4_,
folder5_.lastUpdateTimestamp as lastUpda4_17_4_,
folder5_.leftCol as leftCol17_4_,
folder5_.rightCol as rightCol17_4_,
folder5_.siteId as siteId17_4_,
folder5_.title as title17_4_
from
TextBlockVersionHistory textblockv0_
left outer join
TextBlockVersion textblockv1_
on textblockv0_.activeVersionId=textblockv1_.id
left outer join
TextBlockVersionHistory textblockv2_
on textblockv1_.versionHistoryId=textblockv2_.id
left outer join
TextBlock textblock3_
on textblockv0_.id=textblock3_.versionHistoryId
and ? = textblock3_1_.siteId -- **************************************************
left outer join
AbstractContentObject textblock3_1_
on textblock3_.id=textblock3_1_.id
left outer join
Site site4_
on textblock3_1_.siteId=site4_.id
left outer join
Folder folder5_
on textblock3_1_.folderId=folder5_.id
where
textblockv0_.id=?
The highlighted condition is applied via a filter on AbstractContentObject:
@javax.persistence.Entity
@Inheritance(strategy = InheritanceType.JOINED)
@Filter(name = "siteVisibility", condition = ":siteId = siteId")
@Table(uniqueConstraints = @UniqueConstraint( columnNames = { "folderId", "order"}))
public abstract class AbstractContentObject
However, the actual SQL condition is supplied to the wrong LEFT OUTER JOIN. It should be supplied against the AbstractContentObject JOIN that immediately follows the condition. I.e. move the condition down three lines, and it should work.
--
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
17 years, 3 months
[Hibernate-JIRA] Created: (HHH-2631) Leaking PreparedStatement and ResultSet via CollectionLoadContext instances maintained in Map collectionLoadContexts in LoadContexts
by Douglas A. Herrick (JIRA)
Leaking PreparedStatement and ResultSet via CollectionLoadContext instances maintained in Map collectionLoadContexts in LoadContexts
------------------------------------------------------------------------------------------------------------------------------------
Key: HHH-2631
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2631
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.3
Environment: hibernate 3.2.3 with patch from HHH-2553
Reporter: Douglas A. Herrick
Priority: Critical
While diagnosing an apparent resource issue, while running our application for a couple of hours I noticed over time that the number of PreparedStatement and ResultSet instances continued to grow, eventually consuming a fair amount of memory. After digging around a bit, I saw that the entries LoadContext.java inserts into the map named collectionLoadContexts are not removed from the map [method cleanup(ResultSet resultSet) might have removed them, but I never witnessed its invocation, nor did I find any references to it).
I pasted below a stack trace that shows the insertion of elements into collectionLoadContexts:
Thread [http-9943-Processor2] (Suspended (breakpoint at line 53 in CollectionLoadContext))
CollectionLoadContext.<init>(LoadContexts, ResultSet) line: 53
LoadContexts.getCollectionLoadContext(ResultSet) line: 85
BasicCollectionLoader(Loader).handleEmptyCollections(Serializable[], Object, SessionImplementor) line: 1060
BasicCollectionLoader(Loader).doQuery(SessionImplementor, QueryParameters, boolean) line: 690
BasicCollectionLoader(Loader).doQueryAndInitializeNonLazyCollections(SessionImplementor, QueryParameters, boolean) line: 236
BasicCollectionLoader(Loader).loadCollection(SessionImplementor, Serializable, Type) line: 1994
BasicCollectionLoader(CollectionLoader).initialize(Serializable, SessionImplementor) line: 36
BasicCollectionPersister(AbstractCollectionPersister).initialize(Serializable, SessionImplementor) line: 565
DefaultInitializeCollectionEventListener.onInitializeCollection(InitializeCollectionEvent) line: 60
SessionImpl.initializeCollection(PersistentCollection, boolean) line: 1716
PersistentSet(AbstractPersistentCollection).forceInitialization() line: 454
StatefulPersistenceContext.initializeNonLazyCollections() line: 785
QueryLoader(Loader).doQueryAndInitializeNonLazyCollections(SessionImplementor, QueryParameters, boolean) line: 241
QueryLoader(Loader).doList(SessionImplementor, QueryParameters) line: 2220
QueryLoader(Loader).listIgnoreQueryCache(SessionImplementor, QueryParameters) line: 2104
QueryLoader(Loader).list(SessionImplementor, QueryParameters, Set, Type[]) line: 2099
QueryLoader.list(SessionImplementor, QueryParameters) line: 378
QueryTranslatorImpl.list(SessionImplementor, QueryParameters) line: 338
HQLQueryPlan.performList(QueryParameters, SessionImplementor) line: 172
SessionImpl.list(String, QueryParameters) line: 1121
QueryImpl.list() line: 79
HibQuery.list() line: 60
HibRepository(AbstractRepository).query(IQuery, Class) line: 300
...
While subsequent to this logic, hibernate does close the PreparedStatement and ResultSet instances, since it never removes them from collectionLoadContexts map, those instances are never GCed. After running our application for a couple of days the amount of storage attributed to this potential leak is significant.
--
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
17 years, 3 months
[Hibernate-JIRA] Created: (HHH-2365) Incorrect parameter order for parameters used as map-key in HQL
by Hendrik D (JIRA)
Incorrect parameter order for parameters used as map-key in HQL
---------------------------------------------------------------
Key: HHH-2365
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2365
Project: Hibernate3
Type: Bug
Components: query-hql
Versions: 3.2.1
Reporter: Hendrik D
When using parameters in HQL for the key of a domain object map in the where-clause, the query parsing mechanism results in an SQL query with the parameters used in the wrong places.
Since my real domain objects require you to know too much of the application I'm writing, I'll describe the problem with a simplified setup:
CLASSES:
-------
class Foo {
int id;
int meaninglessNumber;
Map<Language, Document> documents;
}
class Document {
int id;
String name;
}
class Language {
String code;
}
TABLES:
-------
FOO
id
meaninglessNumber
documents_link_id
DOCUMENTS_LINK
documents_link_id
language_code
document_id
name
LANGUAGE
language_code
Now, let't try to retrieve all Foo that contain an english document with name "English", and have a meaninglessNumber of '5'. This is the HQL I produce:
from Foo as foo
where foo.meaninglessNumber = param1
and foo.documents[:param2]=:param3
These are the parameter values:
param1 = int 5
param2 = Language {code="en"}
param3 = String "English"
I expect an sql query like this:
select *
from foo foo0_
inner join documents documents1_
where foo0_.documents_link_id = documents1_.documents_link_id
and documents1_.language_code = 'en'
and foo0_.meaninglessNumber = 5
and documents1_.name = 'English'
But instead, the real query looks like this:
select *
from foo foo0_
inner join documents documents1_
where foo0_.documents_link_id = documents1_.documents_link_id
and documents1_.language_code = 5
and foo0_.meaninglessNumber = 'en'
and documents1_.name = 'English'
The subtle difference is, that the parameters param1 and param2 seem to be switched! A lot of debugging pointed out that the order of the indexes is determined based on the HQL, resulting in the following indexes:
param1 -> 1
param2 -> 2
param3 -> 3
In the generated SQL, all parameters are replaced by '?', and on execution, these are replaced one by one, following the order of the parameter indexes.
While creating the SQL, the map key parameter is transformed into 'documents1_.language_code = ?'. No problem here, but this condition is placed in the beginning of the where clause, before the use of parameter param1. The indexes of the parameters should become:
param2 -> 1
param1 -> 2
param3 -> 3
But this is never done!
I see 3 possible ways to fix this:
- Recalculate the indexes of the parameters when the sql is generated
- Generate the sql in the right position, so the order of the parameters stays the same
- Use named parameters in the sql and only replace them with '?' right before creating the PreparedStatement. This seems to me the most reliable way, but I guess I'm missing the point of calculating the parameter indexes and replacing them with '?' immediately...
Hendrik
--
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
17 years, 3 months