[Hibernate-JIRA] Created: (HHH-5649) improve eclipse support with migration to gradle
by Strong Liu (JIRA)
improve eclipse support with migration to gradle
------------------------------------------------
Key: HHH-5649
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5649
Project: Hibernate Core
Issue Type: Improvement
Reporter: Strong Liu
Assignee: Strong Liu
Fix For: 4.x
currently, I found the following problems when using gradle to generate the eclipse project metadata files:
* [GRADLE-1132|http://jira.codehaus.org/browse/GRADLE-1132] Gradle should generate .settings/org.eclipse.jdt.core.prefs
this means you may need set the project's compile level manually, ATM, jdk6
* [GRADLE-1074|http://jira.codehaus.org/browse/GRADLE-1074] Add eclipse variables to workspace.
the .classpath generated by gradle uses GRADLE_CACHE variable, and this need be added manually, just point it to your $user.home/.gradle/cache
* jacc and ant are not in core's classpath
these two, (and actually others, such validtion, cglib, but these are added to both "provided" and "testRuntime" configuration) are only in the custom "provided" configuration, by default, eclipse plugin don't know how to deal with a customer configuration.
* hibernate-core/src/main/antlr is incorrectly added into classpath
* entitymanager's generate-src is not added into classpath
--
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
14 years, 11 months
[Hibernate-JIRA] Created: (HHH-4770) Wrong class property type, when access="field" is specified. The HbmBinder and the method setTypeUsingReflection() of the interface org.hibernate.mapping.Value does not use the property "access" settings (field/property/etc...)
by Peter Fassev (JIRA)
Wrong class property type, when access="field" is specified. The HbmBinder and the method setTypeUsingReflection() of the interface org.hibernate.mapping.Value does not use the property "access" settings (field/property/etc...)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Key: HHH-4770
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4770
Project: Hibernate Core
Issue Type: Bug
Components: core, metamodel
Affects Versions: 3.5.0-Beta-2, 3.3.2
Reporter: Peter Fassev
Attachments: ReflectionTest.zip
Hibernate provides a possibility to define different access to the class properties for instance trough class methods (access="property") or directly to fields (access="field"). This information is not used during the initialization of the subclasses of the org.hibernate.mapping.Value (see SimpleValue and ToOne).
The Value interface provides a method called setTypeUsingReflection(String className, String propertyName) with only two parameters. Some subclasses like SimpleValue and ToOne are calling the ReflectHelper.reflectedPropertyClass(className, propertyName). The ReflectHelper uses first the BASIC_PROPERTY_ACCESSOR, which always returns the type of the class method. Only if there is no such method, the type of the class field is returned. It does not distinguish between "property" and "field" access. Here is the Method from the ReflectHelper:
org.hibernate.util.ReflectHelper:
private static Getter getter(Class clazz, String name) throws MappingException {
try {
return BASIC_PROPERTY_ACCESSOR.getGetter( clazz, name );
}
catch ( PropertyNotFoundException pnfe ) {
return DIRECT_PROPERTY_ACCESSOR.getGetter( clazz, name );
}
}
In the case the declared method returns a different type as the declared field Hibernate calculates a wrong type for the fild. Consider the following class with a hidden field "rejected" of type "Date" and a method "isRecected()" of type boolean:
class Item {
private Date rejected;
public void doReject() {
rejected = new Date();
}
public boolean isRejected() {
return rejected != null;
}
}
This type of the rejected field will be recognized by Hibernate as "boolean", even if the field access is defined to be "access=field". By running the ReflectionTestCase you will get an exception: "java.util.Date cannot be cast to java.lang.Boolean".
Proposed Resolution:
1) The method org.hibernate.mapping.Value. setTypeUsingReflection needs a new parameter, which provides the access type of the property.
2) The class org.hibernate.mapping.HbmBinder must bind the access attribute of the property prior of calling this method, which is currently not the case (see the method HbmBinder.createProperty()).
3) The classess SimpleValue and ToOne should either use the PropertyAccessorFactory or the ReflectHelper should be extended to handle the access type of the field.
Regards
PF
--
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
14 years, 11 months
[Hibernate-JIRA] Created: (HHH-5292) org.hibernate.ejb.AbstractQueryImpl#registerParameterBinding throws ClassCastException if the parameter value is a primitive type array.
by Jürgen Kellerer (JIRA)
org.hibernate.ejb.AbstractQueryImpl#registerParameterBinding throws ClassCastException if the parameter value is a primitive type array.
----------------------------------------------------------------------------------------------------------------------------------------
Key: HHH-5292
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5292
Project: Hibernate Core
Issue Type: Bug
Components: entity-manager
Affects Versions: 3.5.1
Environment: Hibernate 3.5.1, HSQL 1.8
Reporter: Jürgen Kellerer
When I set a query paramter on a TypedQuery that is a primitive array (in my case byte[]) there will be a ClassCastException inside the method org.hibernate.ejb.AbstractQueryImpl#registerParameterBinding because the method tries to cast byte[] to Object[]:
{noformat}
... else if (value.getClass().isArray()) {
final Object[] array = (Object[]) value;
...
{noformat}
*Produces:*
{noformat}
java.lang.ClassCastException: [B cannot be cast to [Ljava.lang.Object;
at org.hibernate.ejb.AbstractQueryImpl.registerParameterBinding(AbstractQueryImpl.java:348)
at org.hibernate.ejb.QueryImpl.setParameter(QueryImpl.java:359)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at org.springframework.orm.jpa.SharedEntityManagerCreator$DeferredQueryInvocationHandler.invoke(SharedEntityManagerCreator.java:310)
{noformat}
*Reproduction is easy:*
{noformat}
em.createQuery("SELECT e.stringValue FROM entity e WHERE e.guid = :guid",
String.class).setParameter("guid", new byte[16]);
{noformat}
having entity defined as:
{noformat}
@Entity(name = "entity")
public class Entity {
@Column(length=16)
byte[] guid;
@Column
String stringValue;
}
{noformat}
*Solution:*
The solution to the problem is quite simple. By checking list types only if the direct type match doesn't return true, the system doesn't have such an issue. The following patch fixes the bug:
Patch for the method inside org.hibernate.ejb.AbstractQueryImpl.java[274]:
{noformat}
protected void registerParameterBinding(Parameter parameter, Object value) {
final Class<?> targetType = parameter.getParameterType();
if ( value != null && targetType != null ) {
if (!targetType.isInstance(value)) {
if ( Collection.class.isInstance( value ) ) {
final Collection collection = (Collection) value;
// validate the elements...
for ( Object element : collection ) {
if ( ! targetType.isInstance( element ) ) {
throw new IllegalArgumentException(
"Parameter value [" + element + "] was not matching type [" +
targetType.getName() + "]"
);
}
}
} else if ( value.getClass().isArray() ) {
final Object[] array = (Object[]) value;
for ( Object element : array ) {
if ( ! targetType.isInstance( element ) ) {
throw new IllegalArgumentException(
"Parameter value [" + element + "] was not matching type [" +
targetType.getName() + "]"
);
}
}
} else {
throw new IllegalArgumentException(
"Parameter value [" + value + "] was not matching type [" +
targetType.getName() + "]"
);
}
}
}
if ( parameterBindings == null ) {
parameterBindings = new HashMap();
}
parameterBindings.put( parameter, value );
}
{noformat}
--
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
14 years, 11 months
[Hibernate-JIRA] Created: (HHH-5915) Bug with MSSQL Paging released in 3.6.1
by Noel Trout (JIRA)
Bug with MSSQL Paging released in 3.6.1
---------------------------------------
Key: HHH-5915
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5915
Project: Hibernate Core
Issue Type: Bug
Components: core, entity-manager
Affects Versions: 3.6.1
Environment: Hibernate 3.6.1, MSSSQL 2008 R2, JPA 2
Reporter: Noel Trout
This is related to all the changes in 3.6.1 for MSSQL (specifically paging).
http://opensource.atlassian.com/projects/hibernate/secure/IssueNavigator....
When using the new paging, it is no longer possible to create an entity manager criteria query (javax.persistence.criteria) that takes parameters in the ORDER BY portion of the statement at the same time as the WHERE portion has parameters. Hibernate does not throw an exception, but the parameters are bound incorrectly so that when the query is sent to MSSQL a grammar exception is thrown. This is related in some way to how the dialect is transforming the query for the MSSQL Common Table Expression (CTE).
Literal values still work in the ORDER BY portion.
To reproduce, just create query an entity, ensuring there are parameters in both the ORDER BY and WHERE portions.
Example WHERE from Our Code:
criteriaQuery.where(builder.or(
criteriaBuilder.equal(aircraftRoot.get(AircraftEntityImpl_.status), AircraftStatus.PAX_ACTIVE),
criteriaBuilder.equal(aircraftRoot.get(AircraftEntityImpl_.status), AircraftStatus.PAX_CARGO_ACTIVE)
));
Example ORDER BY from our code:
// Broken as of 3.6.1, parameter bound - enum class with EnhancedUserType
final Case<Object> wyvernCase = builder.selectCase();
wyvernCase.when(builder.isNull(wyvernStatusPath), WyvernOperatorStatus.NONE);
wyvernCase.otherwise(wyvernStatusPath);
criteriaQuery.orderBy(criteriaBuilder.desc(wyvernCase));
// Working with 3.6.1, integer literal constant
final Case<Object> wyvernCase = builder.selectCase();
wyvernCase.when(builder.isNull(wyvernStatusPath), builder.literal(WyvernOperatorStatus.NONE.getCode()));
wyvernCase.otherwise(wyvernStatusPath);
criteriaQuery.orderBy(criteriaBuilder.desc(wyvernCase));
--
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
14 years, 11 months
[Hibernate-JIRA] Created: (HHH-4559) Envers AuditMetadata Generator causes java.lang.ClassCastException: org.hibernate.mapping.Formula cannot be cast to org.hibernate.mapping.Column
by Kevin Schmidt (JIRA)
Envers AuditMetadata Generator causes java.lang.ClassCastException: org.hibernate.mapping.Formula cannot be cast to org.hibernate.mapping.Column
------------------------------------------------------------------------------------------------------------------------------------------------
Key: HHH-4559
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4559
Project: Hibernate Core
Issue Type: Bug
Components: envers
Affects Versions: 3.5.0-Beta-2
Environment: Hibernate 3.5.0-Beta-2
RDBMS: Microsoft SQL Server, version: 09.00.4230
JDBC driver: jTDS Type 4 JDBC Driver for MS SQL Server and Sybase, version: 1.2.4
Reporter: Kevin Schmidt
Priority: Blocker
Dear Hibernate Team,
I attempted to enable Envers for a Legacy Hibernate Application which uses hbm.xml based mapping files. The building of the SessionFactory fails due to a class cast exception in the Envers code base. It appears that while generating mapping data in the AuditMetadataGenerator it is assumed that a discriminator is a Column, but it can also be a Formula. This causes a class cast exception to be thrown as is shown below (see the last cause in the exception stack trace). I know the response is going to be attach a test case, but I am not even sure how to create a good test case. Are there instructions on the wiki some where? Some starting project I could use to create the test case? In order to reproduce this issue I think it is as simple as enabling auditing for an entity which has a discriminator based on a formula instead of a column.
[2009.11.10 09:33:32.302 XYZ] Failed to initialize due to exception.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.sessionFactory' defined in class path resource [com/xyz/data/spring-config-data.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: could not init listeners
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$2.getObject(AbstractBeanFactory.java:302)
at com.XYZ.services.springscope.AbstractXYZSpringScopeStrategy.get(AbstractXYZSpringScopeStrategy.java:87)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.aop.target.SimpleBeanTargetSource.getTarget(SimpleBeanTargetSource.java:33)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:184)
at $Proxy6.openSession(Unknown Source)
at com.XYZ.data.hibernate.conversation.Conversation.<init>(Conversation.java:59)
at com.XYZ.data.hibernate.conversation.ConversationManagerImpl.startConversation(ConversationManagerImpl.java:128)
at com.XYZ.data.hibernate.conversation.ConversationManagerImpl.beginConversation(ConversationManagerImpl.java:110)
at com.XYZ.core.initialization.AbstractInitializationThread.run(AbstractInitializationThread.java:145)
at com.XYZ.services.thread.ThreadsManager$ThreadWrapper.run(ThreadsManager.java:147)
at java.lang.Thread.run(Unknown Source)
Caused by: org.hibernate.HibernateException: could not init listeners
at org.hibernate.event.EventListeners.initializeListeners(EventListeners.java:205)
at org.hibernate.cfg.Configuration.getInitializedEventListeners(Configuration.java:1378)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1367)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:858)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:814)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:732)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
... 18 more
Caused by: java.lang.ClassCastException: org.hibernate.mapping.Formula cannot be cast to org.hibernate.mapping.Column
at org.hibernate.envers.configuration.metadata.MetadataTools.addColumns(MetadataTools.java:154)
at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.generateMappingData(AuditMetadataGenerator.java:252)
at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.generateFirstPass(AuditMetadataGenerator.java:327)
at org.hibernate.envers.configuration.EntitiesConfigurator.configure(EntitiesConfigurator.java:87)
at org.hibernate.envers.configuration.AuditConfiguration.<init>(AuditConfiguration.java:86)
at org.hibernate.envers.configuration.AuditConfiguration.getFor(AuditConfiguration.java:99)
at org.hibernate.envers.event.AuditEventListener.initialize(AuditEventListener.java:259)
at org.hibernate.event.EventListeners$1.processListener(EventListeners.java:198)
at org.hibernate.event.EventListeners.processListeners(EventListeners.java:181)
at org.hibernate.event.EventListeners.initializeListeners(EventListeners.java:194)
... 26 more
--
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
14 years, 11 months