[Hibernate-JIRA] Created: (HHH-7216) "java.lang.IllegalStateException: No supertype found" thrown on query with "COUNT" aggregate function
by Tomas Milo (JIRA)
"java.lang.IllegalStateException: No supertype found" thrown on query with "COUNT" aggregate function
-----------------------------------------------------------------------------------------------------
Key: HHH-7216
URL: https://hibernate.onjira.com/browse/HHH-7216
Project: Hibernate ORM
Issue Type: Bug
Components: core, entity-manager, query-criteria
Affects Versions: 4.1.1
Reporter: Tomas Milo
Priority: Critical
I have 2 entities:
{code}
@Entity
public class Transaction
{
@Id
@Column
private Integer trId;
...
}
{code}
{code}
@Entity
public class Form
{
@Id
@OneToOne
@JoinColumn( name = "trId" )
private Transaction transaction;
@Column
private String firstname;
...
}
{code}
And query:
{code}
private EntityManager em;
...
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Long> c = cb.createQuery( Long.class );
Root<Form> form = c.from( Form.class );
c.select( cb.count( form ) );
TypedQuery<Long> q = em.createQuery( c );
int count = q.getResultList().get( 0 ).intValue();
{code}
Following exception was thrown on execution of "TypedQuery<Long> q = em.createQuery( c );":
Caused by: java.lang.IllegalStateException: No supertype found
at org.hibernate.ejb.metamodel.AbstractIdentifiableType.requireSupertype(AbstractIdentifiableType.java:85)
at org.hibernate.ejb.metamodel.AbstractIdentifiableType.getIdType(AbstractIdentifiableType.java:173)
at org.hibernate.ejb.criteria.expression.function.AggregationFunction$COUNT.renderArguments(AggregationFunction.java:110)
at org.hibernate.ejb.criteria.expression.function.ParameterizedFunctionExpression.render(ParameterizedFunctionExpression.java:94)
at org.hibernate.ejb.criteria.expression.function.BasicFunctionExpression.renderProjection(BasicFunctionExpression.java:71)
at org.hibernate.ejb.criteria.QueryStructure.render(QueryStructure.java:250)
at org.hibernate.ejb.criteria.CriteriaQueryImpl.render(CriteriaQueryImpl.java:338)
at org.hibernate.ejb.criteria.CriteriaQueryCompiler.compile(CriteriaQueryCompiler.java:216)
at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:623)
I think the problem is in the org.hibernate.ejb.metamodel.AbstractIdentifiableType.getIdType() function, which is not prepared for "mapped identifier" (as is org.hibernate.ejb.metamodel.MetadataContext.applyIdMetadata procedure).
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 3 months
[Hibernate-JIRA] Created: (HHH-6655) trim function on DB2 is broken
by Strong Liu (JIRA)
trim function on DB2 is broken
------------------------------
Key: HHH-6655
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6655
Project: Hibernate Core
Issue Type: Bug
Affects Versions: 4.0.0.CR2
Reporter: Strong Liu
For DB2 a warning message is generated by TempateRenderer which is not seen for other databases:
WARN: HHH00174:Function template anticipated 3 arguments, but 2 arguments encountered
see test _org.hibernate.ejb.criteria.CriteriaCompilingTest#testTrim_ for more details
Also the query created is different in case of DB2:
Hibernate: select replace(replace(ltrim(rtrim(replace(replace(customer0_.NAME,' ','${space}$'),?,' '))),' ',?),'${space}$',' ') as col_0_0_ from CUSTOMER_TABLE customer0_ where customer0_.NAME=? fetch first 2 rows only
and finally it fails because of above warning:
javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: DB2 SQL Error: SQLCODE=-313, SQLSTATE=07001
For other DBs same code generates following query and test passes:
Hibernate: select trim(BOTH ? from customer0_.NAME) as col_0_0_ from CUSTOMER_TABLE customer0_ where customer0_.NAME=? limit ?
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 3 months
[Hibernate-JIRA] Created: (HHH-2280) Not-Null Constraint-Violation with unidirectional one-to-many mapping
by Robert Herschke (JIRA)
Not-Null Constraint-Violation with unidirectional one-to-many mapping
---------------------------------------------------------------------
Key: HHH-2280
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2280
Project: Hibernate3
Type: Bug
Versions: 3.2.0.cr4
Environment: Hibernate 3.2.0.cr4, Oracle 10XE
Reporter: Robert Herschke
Priority: Blocker
Attachments: one-to-many-test.zip
In some cases it is neccessary to have an unidirectional one-to-many mapping, but not using Join-Tables due to a legacy database system.
So it must be possible, to have a one-to-many mapping just via a foreign-key-mapping. The Child-Object must not know the Parent-Object in this case.
It must also be possible, to pay respect to a NOT-NULL-Constraint at this foreign-key due to restrictions on legacy database systems.
Hibernate doesn't support this, but throw a NOT-NULL-Constraint Violation Exception. The documentation says, "this is unusual" - to which I want to dissent.
See the attached testcase for details, that is adopted from your "one-to-many" testcase found in the 3.2.0 sources.
--
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, 3 months
[Hibernate-JIRA] Created: (HHH-4459) Query with Composite Primary Key parameter crashes when query cache is on
by Karol Bienkowski (JIRA)
Query with Composite Primary Key parameter crashes when query cache is on
-------------------------------------------------------------------------
Key: HHH-4459
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4459
Project: Hibernate Core
Issue Type: Bug
Components: caching (L2)
Affects Versions: 3.3.2
Environment: Hibernate Core 3.3.2.GA, MySQL and H2
Reporter: Karol Bienkowski
I have an entity with a composite identifier (primary key) annotated with EmbeddedId:
@Embeddable
public class CompositeKey implements Serializable {
(...)
}
@Entity
public class EntityWithCompositeKey {
@EmbeddedId
public CompositeKey pk;
(...)
}
When executing query ...
FROM EntityWithCompositeKey e WHERE e.pk = :pk
... where ":pk" is bound to an instance of CompositeKey ...
query.setParamter("pk", new CompositeKey(..))
... I get the following exception:
javax.persistence.PersistenceException: org.hibernate.PropertyAccessException: could not get a field value by reflection getter of hhhxxxx.CompositeKey.a
at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:614)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:76)
at hhhxxxx.HHHHxxxxTest.testGetByCompositeId(HHHHxxxxTest.java:46)
(...)
Caused by: org.hibernate.PropertyAccessException: could not get a field value by reflection getter of hhhxxxx.CompositeKey.a
at org.hibernate.property.DirectPropertyAccessor$DirectGetter.get(DirectPropertyAccessor.java:58)
at org.hibernate.tuple.component.AbstractComponentTuplizer.getPropertyValue(AbstractComponentTuplizer.java:87)
at org.hibernate.tuple.component.AbstractComponentTuplizer.getPropertyValues(AbstractComponentTuplizer.java:93)
at org.hibernate.tuple.component.PojoComponentTuplizer.getPropertyValues(PojoComponentTuplizer.java:109)
at org.hibernate.type.ComponentType.getPropertyValues(ComponentType.java:376)
at org.hibernate.type.ComponentType.getHashCode(ComponentType.java:194)
at org.hibernate.engine.TypedValue.hashCode(TypedValue.java:66)
at java.util.HashMap$Entry.hashCode(Unknown Source)
at java.util.AbstractMap.hashCode(Unknown Source)
at org.hibernate.cache.QueryKey.generateHashCode(QueryKey.java:196)
at org.hibernate.cache.QueryKey.<init>(QueryKey.java:173)
at org.hibernate.cache.QueryKey.generateQueryKey(QueryKey.java:128)
at org.hibernate.loader.Loader.listUsingQueryCache(Loader.java:2144)
at org.hibernate.loader.Loader.list(Loader.java:2121)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:363)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1149)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:67)
... 21 more
Caused by: java.lang.IllegalArgumentException: Can not set int field hhhxxxx.CompositeKey.a to [Ljava.lang.Object;
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(Unknown Source)
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(Unknown Source)
at sun.reflect.UnsafeFieldAccessorImpl.ensureObj(Unknown Source)
at sun.reflect.UnsafeIntegerFieldAccessorImpl.getInt(Unknown Source)
at sun.reflect.UnsafeIntegerFieldAccessorImpl.get(Unknown Source)
at java.lang.reflect.Field.get(Unknown Source)
at org.hibernate.property.DirectPropertyAccessor$DirectGetter.get(DirectPropertyAccessor.java:55)
... 40 more
It used to work on 3.3.1.GA but fails in 3.3.2.GA. Turning off query cache works.
The direct reason for the error is that TypedValue.value is an Object[] but ComponentType.getHashCode() expects TypedValue.value to be of CompositeKey type.
I'll attach the working test case replicating the issue in a moment.
--
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, 3 months
[Hibernate-JIRA] Created: (HHH-6005) DefaultComponentSafeNamingStrategy breaks @ElementCollection of @Embeddables
by Artem Troitskiy (JIRA)
DefaultComponentSafeNamingStrategy breaks @ElementCollection of @Embeddables
----------------------------------------------------------------------------
Key: HHH-6005
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6005
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.5.0-Final
Reporter: Artem Troitskiy
Priority: Minor
{{DefaultComponentSafeNamingStrategy}} is incompatible with {{@ElementCollection}} of {{@Embeddable}} objects.
Given the following classes
{code:java}
@Entity
public class Foo {
@ElementCollection
private List<Bar> bars;
...
}
@Embeddable
public class Bar {
private String name;
...
}
{code}
and DefaultComponentSafeNamingStrategy as a naming strategy, Hibernate generates the schema with the following incorrect table:
bq. create table Foo_bars (Foo_id bigint not null, bars_collection&&element_name varchar(255))
{{.collection&&element.}} is an internal placeholder that should be removed before use of property name. Other naming strategies effectively remove it by using the part of property name after the last {{.}}, but {{DefaultComponentSafeNamingStrategy}} doesn't, it just replaces {{.}} with {{_}}.
Here is a workaround:
{code:java}
public class FixedDefaultComponentSafeNamingStrategy extends DefaultComponentSafeNamingStrategy {
@Override
public String propertyToColumnName(String propertyName) {
return super.propertyToColumnName(propertyName.replace(".collection&&element.", "."));
}
}
{code}
--
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, 3 months