Class EnumStringType

  • All Implemented Interfaces:
    org.hibernate.usertype.ParameterizedType, org.hibernate.usertype.UserType

    public class EnumStringType
    extends java.lang.Object
    implements org.hibernate.usertype.UserType, org.hibernate.usertype.ParameterizedType
    In java an Enum and in database a String corresponding to the position in the string that it's in property 'strings'.

    Example of use:

    Author:
    David Buedo
    • Constructor Summary

      Constructors 
      Constructor Description
      EnumStringType()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Object assemble​(java.io.Serializable cached, java.lang.Object owner)  
      java.lang.Object deepCopy​(java.lang.Object obj)  
      java.io.Serializable disassemble​(java.lang.Object obj)  
      boolean equals​(java.lang.Object obj1, java.lang.Object obj2)  
      java.lang.String getEnumType()
      Full qualified class for the Enum.
      java.lang.String getStrings()
      String that corresponds with the valid values for this enum.
      int hashCode​(java.lang.Object obj)  
      boolean isMutable()  
      java.lang.Object nullSafeGet​(java.sql.ResultSet resultSet, java.lang.String[] names, org.hibernate.engine.spi.SharedSessionContractImplementor sessionImplementor, java.lang.Object owner)  
      void nullSafeSet​(java.sql.PreparedStatement ps, java.lang.Object value, int index, org.hibernate.engine.spi.SharedSessionContractImplementor sessionImplementor)  
      java.lang.Object replace​(java.lang.Object original, java.lang.Object target, java.lang.Object owner)  
      java.lang.Class returnedClass()  
      void setEnumType​(java.lang.String enumType)
      Full qualified class for the Enum.
      void setParameterValues​(java.util.Properties parameters)  
      void setStrings​(java.lang.String strings)
      String that corresponds with the valid values for this enum.
      int[] sqlTypes()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • EnumStringType

        public EnumStringType()
    • Method Detail

      • sqlTypes

        public int[] sqlTypes()
        Specified by:
        sqlTypes in interface org.hibernate.usertype.UserType
      • returnedClass

        public java.lang.Class returnedClass()
        Specified by:
        returnedClass in interface org.hibernate.usertype.UserType
      • equals

        public boolean equals​(java.lang.Object obj1,
                              java.lang.Object obj2)
                       throws org.hibernate.HibernateException
        Specified by:
        equals in interface org.hibernate.usertype.UserType
        Throws:
        org.hibernate.HibernateException
      • hashCode

        public int hashCode​(java.lang.Object obj)
                     throws org.hibernate.HibernateException
        Specified by:
        hashCode in interface org.hibernate.usertype.UserType
        Throws:
        org.hibernate.HibernateException
      • nullSafeGet

        public java.lang.Object nullSafeGet​(java.sql.ResultSet resultSet,
                                            java.lang.String[] names,
                                            org.hibernate.engine.spi.SharedSessionContractImplementor sessionImplementor,
                                            java.lang.Object owner)
                                     throws org.hibernate.HibernateException,
                                            java.sql.SQLException
        Specified by:
        nullSafeGet in interface org.hibernate.usertype.UserType
        Throws:
        org.hibernate.HibernateException
        java.sql.SQLException
      • nullSafeSet

        public void nullSafeSet​(java.sql.PreparedStatement ps,
                                java.lang.Object value,
                                int index,
                                org.hibernate.engine.spi.SharedSessionContractImplementor sessionImplementor)
                         throws org.hibernate.HibernateException,
                                java.sql.SQLException
        Specified by:
        nullSafeSet in interface org.hibernate.usertype.UserType
        Throws:
        org.hibernate.HibernateException
        java.sql.SQLException
      • setParameterValues

        public void setParameterValues​(java.util.Properties parameters)
        Specified by:
        setParameterValues in interface org.hibernate.usertype.ParameterizedType
      • deepCopy

        public java.lang.Object deepCopy​(java.lang.Object obj)
                                  throws org.hibernate.HibernateException
        Specified by:
        deepCopy in interface org.hibernate.usertype.UserType
        Throws:
        org.hibernate.HibernateException
      • isMutable

        public boolean isMutable()
        Specified by:
        isMutable in interface org.hibernate.usertype.UserType
      • disassemble

        public java.io.Serializable disassemble​(java.lang.Object obj)
                                         throws org.hibernate.HibernateException
        Specified by:
        disassemble in interface org.hibernate.usertype.UserType
        Throws:
        org.hibernate.HibernateException
      • assemble

        public java.lang.Object assemble​(java.io.Serializable cached,
                                         java.lang.Object owner)
                                  throws org.hibernate.HibernateException
        Specified by:
        assemble in interface org.hibernate.usertype.UserType
        Throws:
        org.hibernate.HibernateException
      • replace

        public java.lang.Object replace​(java.lang.Object original,
                                        java.lang.Object target,
                                        java.lang.Object owner)
                                 throws org.hibernate.HibernateException
        Specified by:
        replace in interface org.hibernate.usertype.UserType
        Throws:
        org.hibernate.HibernateException
      • getEnumType

        public java.lang.String getEnumType()
        Full qualified class for the Enum. <p> For example: "model.EntityName$EnumName"
      • setEnumType

        public void setEnumType​(java.lang.String enumType)
        Full qualified class for the Enum. <p> For example: "model.EntityName$EnumName"
      • getStrings

        public java.lang.String getStrings()
        String that corresponds with the valid values for this enum. <p> For example, "ALTA,MEDIA,BAJA", means: <ul> <li> ordinal 0 in Java Enum for 'ALTA' in DB <li> ordinal 1 in Java Enum for 'MEDIA' in DB <li> ordinal 2 in Java Enum for 'BAJA' in DB <li> </ul>
      • setStrings

        public void setStrings​(java.lang.String strings)
        String that corresponds with the valid values for this enum. <p> For example, "ALTA,MEDIA,BAJA", means: <ul> <li> ordinal 0 in Java Enum for 'ALTA' in DB <li> ordinal 1 in Java Enum for 'MEDIA' in DB <li> ordinal 2 in Java Enum for 'BAJA' in DB <li> </ul>