[hibernate-issues] [Hibernate-JIRA] Created: (HHH-3013) value not necessary is mappingClass but should return ClassType, getTypedValue(Criteria subcriteria, String propertyName, Object value)

kinfei (JIRA) noreply at atlassian.com
Thu Dec 13 04:23:57 EST 2007


value not necessary is mappingClass but should return ClassType, getTypedValue(Criteria subcriteria, String propertyName, Object value)
---------------------------------------------------------------------------------------------------------------------------------------

                 Key: HHH-3013
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3013
             Project: Hibernate3
          Issue Type: Bug
         Environment: 3.2.5, mysql
            Reporter: kinfei
            Priority: Critical


Criteria criteria = this.createCriteria( Entity.class ).add( Restrictions.eq( "entityClass", Entity.class ) );
--> throw QueryException( "Unsupported discriminator type " + type )

public Entity {
   private Class entityClass;

   public void setEntityClass( Class entityClass ) {
 .....
}


<class name="Entity" table="tbl_entity">
        <id 
            name="id" 
            column="ENTITY_ID"
            type="java.lang.Long"
            unsaved-value="-1" >
            <generator class="increment" />
        </id>
        <property
            name="entityClass"
            column="ENTITY_CLASS"
            type="java.lang.Class"
            length="50"
            not-null="true" 
        />


/**
	 * Get the a typed value for the given property value.
	 */
	public TypedValue getTypedValue(Criteria subcriteria, String propertyName, Object value)
			throws HibernateException {
		// Detect discriminator values...
		if ( value instanceof Class ) {
			Class entityClass = ( Class ) value;
			Queryable q = SessionFactoryHelper.findQueryableUsingImports( sessionFactory, entityClass.getName() ); //=====>return mapping class
			if ( q != null ) {
				Type type = q.getDiscriminatorType();
				String stringValue = q.getDiscriminatorSQLValue();
				// Convert the string value into the proper type.
				if ( type instanceof NullableType ) {
					NullableType nullableType = ( NullableType ) type;
					value = nullableType.fromStringValue( stringValue );
				}
				else {
					throw new QueryException( "Unsupported discriminator type " + type );
				}



-- 
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.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list