[Hibernate-JIRA] Created: (HHH-2052) org.hibernate.pretty.MessageHelper.collectionInfoString tries to cast wrong object to String, causes ClassCastException
by Tree 'Huggy Bear' Hugger (JIRA)
org.hibernate.pretty.MessageHelper.collectionInfoString tries to cast wrong object to String, causes ClassCastException
-----------------------------------------------------------------------------------------------------------------------
Key: HHH-2052
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2052
Project: Hibernate3
Type: Bug
Reporter: Tree 'Huggy Bear' Hugger
Attachments: bugtest.zip
Debug level logging attempted by MessageHelper falls over when constructing a loggable string for a mapped collection on the main entity.
Following the code in the stacktrace, I can see that MessageHelper expects the parent key for the collection relationship to be the primary key, but it is mapped to another field of a different type via a property-ref. Hence the ClassCastException below.
The work around is to set logging to INFO or higher.
I have also attached a pared-down zip with the maven 2 project containing the mappings and the unit test which fails.
The following JIRA issue may be the same thing:
http://opensource.atlassian.com/projects/hibernate/browse/ANN-298
The following messages on the Hib forum demonstrate other interest in this issue:
http://forum.hibernate.org/viewtopic.php?t=949913
http://forum.hibernate.org/viewtopic.php?t=956778
http://forum.hibernate.org/viewtopic.php?t=962471
java.lang.ClassCastException: com.nomadsoft.cortex.domain.country.basic.BasicCountry
at org.hibernate.type.StringType.toString(StringType.java:44)
at org.hibernate.type.NullableType.toLoggableString(NullableType.java:168)
at org.hibernate.pretty.MessageHelper.collectionInfoString(MessageHelper.java:284)
at org.hibernate.loader.Loader.readCollectionElement(Loader.java:972)
at org.hibernate.loader.Loader.readCollectionElements(Loader.java:635)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:580)
at org.hibernate.loader.Loader.doQuery(Loader.java:689)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1785)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:47)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:41)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:2730)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:365)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:346)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:123)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:177)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:87)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:862)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:799)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:792)
at org.springframework.orm.hibernate3.HibernateTemplate$1.doInHibernate(HibernateTemplate.java:452)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:366)
at org.springframework.orm.hibernate3.HibernateTemplate.get(HibernateTemplate.java:446)
at org.springframework.orm.hibernate3.HibernateTemplate.get(HibernateTemplate.java:440)
at com.nomadsoft.cortex.infrastructure.hibernate.HibernateCountryRepository.getById(HibernateCountryRepository.java:26)
at com.nomadsoft.cortex.domain.country.basic.BasicCountryService.getCountry(BasicCountryService.java:34)
etc etc
--
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
12 years, 11 months
[Hibernate-JIRA] Created: (METAGEN-76) SingularAttribute generated for hashCode method in @Embeddable
by Hrotkó Gábor (JIRA)
SingularAttribute generated for hashCode method in @Embeddable
--------------------------------------------------------------
Key: METAGEN-76
URL: http://opensource.atlassian.com/projects/hibernate/browse/METAGEN-76
Project: Hibernate Metamodel Generator
Issue Type: Bug
Components: processor
Affects Versions: 1.1.1.Final
Environment: hibernate-jpamodelgen 1.1.1.Final, postgresql 8
Reporter: Hrotkó Gábor
Assignee: Hardy Ferentschik
I got a class composite id class for a table with @Embeddable.
It has two properties, and the equals and the hashCode methods.
When hibernate-jpamodelgen 1.1.1.Final generates the metaclasses, I got a SingularAttribute with the name "hashCode" generated. But hashCode is not a property in the entity.
entity:
/** by hbm2java */
@Embeddable
public class MyTableId implements java.io.Serializable {
private String id;
private Integer memberId;
public MyTableId() {
}
public MyTableId(String id, Integer memberId) {
this.id = id;
this.memberId = memberId;
}
@Column(name="id")
public String getId() {
return this.id;
}
public void setId(String id) {
this.id = id;
}
@Column(name="member_id")
public Integer getMemberId() {
return this.memberId;
}
public void setMemberId(Integer memberId) {
this.memberId = memberId;
}
public boolean equals(Object other) {
if ( (this == other ) ) return true;
if ( (other == null ) ) return false;
if ( !(other instanceof MyTableId) ) return false;
MyTableId castOther = ( MyTableId ) other;
return ( (this.getId()==castOther.getId()) || ( this.getId()!=null && castOther.getId()!=null && this.getId().equals(castOther.getId()) ) )
&& ( (this.getMemberId()==castOther.getMemberId()) || ( this.getMemberId()!=null && castOther.getMemberId()!=null && this.getMemberId().equals(castOther.get
MemberId()) ) );
}
public int hashCode() {
int result = 17;
result = 37 * result + ( getId() == null ? 0 : this.getId().hashCode() );
result = 37 * result + ( getMemberId() == null ? 0 : this.getMemberId().hashCode() );
return result;
}
}
metaclass:
@StaticMetamodel(MyTableId.class)
public abstract class MyTableId_ {
public static volatile SingularAttribute<MyTableId, String> id;
public static volatile SingularAttribute<MyTableId, Integer> hashCode;
public static volatile SingularAttribute<MyTableId, Integer> memberId;
}
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 11 months
[Hibernate-JIRA] Created: (HHH-4550) query cache: Attention with configuring Update Timestamps Cache region: expired entries cause wrong result sets!
by Guenther Demetz (JIRA)
query cache: Attention with configuring Update Timestamps Cache region: expired entries cause wrong result sets!
----------------------------------------------------------------------------------------------------------------
Key: HHH-4550
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4550
Project: Hibernate Core
Issue Type: Improvement
Components: caching (L2)
Affects Versions: 3.3.2
Environment: 3.3.2 GA
Reporter: Guenther Demetz
Priority: Trivial
Attachments: TestCaseQuryCache.jar
When using hibernate's query cache (hibernate.cache.use_query_cache),
then it's of fundamental importance to configure the Update Timestamps cache region in
a way that his entries survive longer than the cached result sets in the Query cache region.
Otherwise queries could return wrong (obsolete) result sets (See attached testcase).
This is because the current UpdateTimestampsCache#isUpToDate implementation considers a result-set also as up-to-date,
if there are no update-timestamps cached for the interested spaces (tables) at all.
It if therefore important to notice that:
1- The Update-Timestamps-Cache-Region elements max-size should be configured higher than the number of tables you have
on the db-schema, in manner that he can remember/hold the last update-timestamp for each table.
2- If you use any other eviction policy in the Update-Timestamps-Cache-Region, then you must assure
that cached result sets in the Query-cache-region are evicted before relevant update-timestamps are going to be evicted.
This fact should be clearly documented somewhere.
Thanks
G.D.
--
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
12 years, 11 months
[Hibernate-JIRA] Created: (HHH-3892) Improve support for mapping SQL LONGVARCHAR and CLOB to Java String, SQL LONGVARBINARY and BLOB to Java byte[]
by Gail Badner (JIRA)
Improve support for mapping SQL LONGVARCHAR and CLOB to Java String, SQL LONGVARBINARY and BLOB to Java byte[]
---------------------------------------------------------------------------------------------------------------
Key: HHH-3892
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3892
Project: Hibernate Core
Issue Type: Improvement
Components: core
Reporter: Gail Badner
Assignee: Gail Badner
Fix For: 3.2.x, 3.3.x, 3.5
Property types will be provided to enable an application to process data for a java.sql.Types.LONGVARCHAR or java.sql.Types.CLOB column as a Java String. Hibernate will internally process the data as a streams. On a read, stream data will immediately be materialized into a Java string.
text - property type to map java.sql.Types.LONGVARCHAR column data as a Java String (via org.hibernate.type.TextType);
(NOTE: currently, org.hibernate.type.TextType incorrectly maps "text" to java.sql.Types.CLOB; this will be fixed by this issue and updated in database dialects)
materialized_clob - property type to map java.sql.Types.CLOB column data as a Java String (via org.hibernate.type.MaterializedClobType);
In addition, new property types will be provided to enable an application to process data for a java.sql.Types.LONGVARBINARY or java.sql.Types.BLOB column as Java byte[]. Hibernate will internally process the data as a streams. On a read, stream data will immediately be materialized into a Java byte[].
image - property type to map java.sql.Types.LONGVARBINARY column data as byte[] (via org.hibernate.type.ImageType);
materialized_blob - property type to map java.sql.Types.BLOB column data as byte[] (via org.hibernate.type.MaterializedBlobType);
--
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
12 years, 11 months