[jboss-jira] [JBoss JIRA] (WFLY-11991) Add Hibernate ORM transformer option to transform any method parameter of type org.hibernate.engine.spi.SessionImplementor
Scott Marlow (Jira)
issues at jboss.org
Wed May 22 10:50:01 EDT 2019
[ https://issues.jboss.org/browse/WFLY-11991?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Scott Marlow updated WFLY-11991:
--------------------------------
Comment: was deleted
(was: we don't need this change any more, but in case we are interested in it in the future, below is some key parts from [https://github.com/scottmarlow/wildfly/commit/ba6b2918e65be46104fbc90b676802edbe796da7]
{code}
if (parentClassesAndInterfaces.contains("org/hibernate/usertype/CompositeUserType")) {
if (name.equals("nullSafeGet") &&
match(desc,"(Ljava/sql/ResultSet;[Ljava/lang/String;Lorg/hibernate/engine/spi/SessionImplementor;Ljava/lang/Object;)Ljava/lang/Object;")) {
desc = replaceSessionImplementor(desc);
} else if (name.equals("nullSafeSet") &&
match(desc,"(Ljava/sql/PreparedStatement;Ljava/lang/Object;ILorg/hibernate/engine/spi/SessionImplementor;)V")) {
desc = replaceSessionImplementor(desc);
} else if (name.equals("assemble") &&
match(desc,"(Ljava/io/Serializable;Lorg/hibernate/engine/spi/SessionImplementor;Ljava/lang/Object;)Ljava/lang/Object;")) {
desc = replaceSessionImplementor(desc);
} else if (name.equals("disassemble") &&
match(desc,"(Ljava/lang/Object;Lorg/hibernate/engine/spi/SessionImplementor;)Ljava/io/Serializable;")) {
desc = replaceSessionImplementor(desc);
} else if (name.equals("replace") &&
match(desc,"(Ljava/lang/Object;Ljava/lang/Object;Lorg/hibernate/engine/spi/SessionImplementor;Ljava/lang/Object;)Ljava/lang/Object;")) {
desc = replaceSessionImplementor(desc);
}
rewriteSessionImplementor = true;
}
{code}
{code}
private static boolean match(String desc, String check) {
Type[] descType = Type.getArgumentTypes(desc);
Type[] checkType = Type.getArgumentTypes(check);
if(checkType.length != descType.length) {
return false;
}
for(int looper=0; looper < checkType.length; looper++) {
if ( ! matchWildcard(descType[looper], checkType[looper]) &&
! checkType[looper].equals(descType[looper])) {
return false;
}
}
return true;
}
// return true if both parameter types are Objects and checkType is java.lang.Object (treat as match any object)
private static boolean matchWildcard(Type descType, Type checkType) {
return checkType.getDescriptor().startsWith("L") &&
descType.getDescriptor().startsWith("L") &&
checkType.getInternalName().equals("java/lang/Object");
}
{code})
> Add Hibernate ORM transformer option to transform any method parameter of type org.hibernate.engine.spi.SessionImplementor
> --------------------------------------------------------------------------------------------------------------------------
>
> Key: WFLY-11991
> URL: https://issues.jboss.org/browse/WFLY-11991
> Project: WildFly
> Issue Type: Bug
> Components: JPA / Hibernate
> Reporter: Scott Marlow
> Assignee: Scott Marlow
> Priority: Major
> Fix For: 17.0.0.Beta1
>
> Attachments: afterchange.zip, beforechange.zip
>
>
> The idea is to transform any class method parameter of type org.hibernate.engine.spi.SessionImplementor, in user application, to instead use type org.hibernate.engine.spi.SharedSessionContractImplementor.
> The test case (change) is for this enhancement is [https://github.com/simkam/wildfly/compare/hibernate_transformer].
> The test case change is adding an internalNullSafeGet method that should also be transformed to use the SharedSessionContractImplementor type but was not, which led to an application failure with code:
> {code}
> public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException {
> return internalNullSafeGet(rs, names, session, owner);
> }
> private Object internalNullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException {
> internalSessionImplementorUsingMethod(session);
> session.isTransactionInProgress();
> int result = rs.getInt( names[0] );
> if ( rs.wasNull() ) return null;
> return State.values()[result];
> }
> }
> {code}
--
This message was sent by Atlassian Jira
(v7.12.1#712002)
More information about the jboss-jira
mailing list