[hibernate-issues] [Hibernate-JIRA] Created: (HHH-3426) not-null="true" in a composite-element results in bad DDL for mysql 5.0 being generated.

Patrick Moore (JIRA) noreply at atlassian.com
Sun Aug 10 20:21:09 EDT 2008


not-null="true" in a composite-element results in bad DDL for mysql 5.0 being generated.
----------------------------------------------------------------------------------------

                 Key: HHH-3426
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3426
             Project: Hibernate3
          Issue Type: Bug
    Affects Versions: 3.2.6
         Environment: mysql 5.0.51b
            Reporter: Patrick Moore


 * define a map with composite-elements
 * the composite-element has not-null="true" properties
 * the composite-element has some not-null="false" properties ( show for completeness ) 
 * the composite-element has properties with no not-null information.

The problem:

If the composite-element property has not-null="true" then the database column is created with Null=NO but a default value of NULL

If the composite-element property has not-null="false" or no not-null property then the database column is create NULL=NO but no default value.

--------
This behavior seems wrong because 

 1. this composite-element is within a map. According to the documentation only if the composite-element is within a set is the composite-element required to have all non-null values.
 2. if the non-null="true" the default is NULL and non-null="false" results in no default. I believe this is reversed from the correct behavior.

--------

    <class name="com.amplafi.iomanagement.resources.ExternalServicesDefinition" table="RESOURCE_REPOSITORY">
        <id name="entityId" column="ID" access="field">
            <generator class="native"/>
        </id>
        <property name="namespace" column="NAMESPACE" length="30" not-null="true" access="field"/>
        <property name="displayName" column="DISPLAY_NAME" not-null="true" length="100" access="field"/>
        <property name="serviceId" column="SERVICE_ID" not-null="true" length="75">
        <!-- may be calculated by looking at the managingService -->
        </property>
        <property name="serviceUrl" column="SERVICE_URI" not-null="true" length="75" access="field"/>
        <property name="connectionUrl" column="CONNECTION_URI"  length="75" access="field"/>
        <property name="urlPattern" column="URI_PATTERN" length="75" access="field"/>
        <property name="defaultAuthorizationNamespace" column="AUTH_NAMESPACE" length="30" access="field"/>
        <property name="instanceNamespaceParameter" column="INST_NAMESPACE_PARAM" length="30" access="field"/>
        <property name="serviceVersion" column="SERVICE_VERSION" length="30" access="field"/>
        <property name="nature" column="NATURE" length="200" access="field"/>
        <property name="createTime" column="CREATE_DATE" not-null="true" access="field"/>
        <property name="lastUpdate" column="UPDATE_DATE" not-null="true" access="field"/>
        <property name="inactiveState" column="INACTIVE" length="3" access="field">
            <type name="com.amplafi.foundation.persistence.usertypes.PersistedEnumType">
                <param name="enumClass">com.amplafi.foundation.InactiveState</param>
            </type>
        </property>
        <property name="supportedResourceTypes" column="SUPPORTED_TYPES" access="field" length="50">
            <type name="com.amplafi.foundation.persistence.usertypes.JsonArrayUserType">
                <param name="enumClass">com.amplafi.iomanagement.file.ResourceType</param>
            </type>
        </property>
        <map name="externalServicesDefinitionProperties" table="EXTERNAL_SERVICE_PROPERTIES" lazy="true" access="field">
            <key column="EXTERNAL_SERVICES_DEFINITION" foreign-key="FK_EXTERNAL_SERVICE__EXTERNAL_SERVICE_PROPERTIES"/>
            <map-key type="string" formula="AMPLAFI_KEY"/>
            <composite-element class="com.amplafi.iomanagement.resources.ExternalServicesDefinitionProperty">
                <property name="amplafiKey" column="AMPLAFI_KEY" length="30"/>
                <property name="serviceKey" column="SERVICE_KEY" not-null="true" length="30" access="field"/>
                <property name="displayName" column="DISPLAY_NAME" not-null="true" length="50"/>
                <property name="description" column="DESCRIPTION" not-null="true" length="100" access="field"/>
                <property name="initial" column="INITIAL_VAL" length="100" not-null="true" access="field"/>
                <!-- TODO should really be Uri ... used to get things like auth codes -->
                <property name="link" column="PAGELINK" length="100" not-null="false" access="field"/>
                <property name="constant" column="CONSTANT" not-null="true" access="field"/>
                <property name="writeRequires" column="WRITE_REQS" not-null="true" access="field"/>
                <property name="readRequires" column="READ_REQS" not-null="true" access="field"/>
                <property name="secret" column="SECRET" not-null="true" access="field"/>
                <property name="valueHidden" column="HID_VALUE" not-null="true" access="field"/>
                <property name="depends" column="DEPENDS" length="200" not-null="false" access="field"/>
            </composite-element>
        </map>

    </class>


mysql> desc EXTERNAL_SERVICE_PROPERTIES;
+------------------------------+--------------+------+-----+---------+-------+
| Field                        | Type         | Null | Key | Default | Extra |
+------------------------------+--------------+------+-----+---------+-------+
| EXTERNAL_SERVICES_DEFINITION | bigint(20)   | NO   | PRI | NULL    |       | 
| AMPLAFI_KEY                  | varchar(30)  | NO   | PRI |         |       | 
| SERVICE_KEY                  | varchar(30)  | NO   | PRI | NULL    |       | 
| DISPLAY_NAME                 | varchar(50)  | NO   | PRI | NULL    |       | 
| DESCRIPTION                  | varchar(100) | NO   | PRI | NULL    |       | 
| INITIAL_VAL                  | varchar(100) | NO   | PRI | NULL    |       | 
| PAGELINK                     | varchar(100) | NO   | PRI |         |       | 
| CONSTANT                     | bit(1)       | NO   | PRI | NULL    |       | 
| WRITE_REQS                   | bit(1)       | NO   | PRI | NULL    |       | 
| READ_REQS                    | bit(1)       | NO   | PRI | NULL    |       | 
| SECRET                       | bit(1)       | NO   | PRI | NULL    |       | 
| HID_VALUE                    | bit(1)       | NO   | PRI | NULL    |       | 
| DEPENDS                      | varchar(200) | NO   | PRI |         |       | 
+------------------------------+--------------+------+-----+---------+-------+
13 rows in set (0.00 sec)


-- 
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