[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-3151) using property-ref and not-null="true" simultaneously in collection <key> element crashes with ArgumentIllegalException

Gail Badner (JIRA) noreply at atlassian.com
Mon Mar 3 11:47:33 EST 2008


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-3151?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_29649 ] 

Gail Badner commented on HHH-3151:
----------------------------------

Please attach a runnable test case (Java + mapping) that reproduces the problem.

> using property-ref and not-null="true" simultaneously in collection <key> element crashes with ArgumentIllegalException
> -----------------------------------------------------------------------------------------------------------------------
>
>                 Key: HHH-3151
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3151
>             Project: Hibernate3
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.2.5
>         Environment: hibernate 3.2.5
>            Reporter: boris schukin
>
> Example: 
> Let's  we have one class "MetaMethod"  and  second class "MetaParameter" .
> Class MetaMethod has a list of MetaParameters.
> Corresponding tables are: 
> CREATE TABLE META_METHOD
>  (ID VARCHAR2(50) NOT NULL
>  ,CODE VARCHAR2(40) NOT NULL
>  ,BCN_CODE VARCHAR2(40) NOT NULL
>  ,NAME VARCHAR2(100)
>  )
> ALTER TABLE META_METHOD  ADD (CONSTRAINT SK_BFN_PK PRIMARY KEY   (ID))
> ALTER TABLE META_METHOD ADD (CONSTRAINT SK_BFN_UK1 UNIQUE   (CODE  ,BCN_CODE))
> CREATE TABLE META_PARAMETER
>  (ID VARCHAR2(50) NOT NULL
>  ,BFN_CODE VARCHAR2(40) NOT NULL
>  ,BCN_CODE VARCHAR2(40) NOT NULL
>  ,SEQUENCE_NUMBER NUMBER(4,0) NOT NULL
>  ,TYPE VARCHAR2(255) NOT NULL
>   )
> ALTER TABLE META_PARAMETER  ADD (CONSTRAINT SK_BFA_PK PRIMARY KEY   (ID))
> ALTER TABLE META_PARAMETER ADD (CONSTRAINT SK_BFA_UK1 UNIQUE    (BFN_CODE, BCN_CODE   ,SEQUENCE_NUMBER))
> ALTER TABLE META_PARAMETER ADD (CONSTRAINT SK_BFA_BFN_FK1 FOREIGN KEY   (BFN_CODE  ,BCN_CODE) REFERENCES  META_METHOD (CODE   ,BCN_CODE))
> You see, the foreign key (BFN_CODE  ,BCN_CODE) on the table META_PARAMETER  is organized by native key (CODE  ,BCN_CODE) of the META_METHOD table.
> Structure of classes is simple (in my opinion), so i introduce the hibernate mappings: 
> <class name="com.stinscoman.kernel.api.meta.MetaMethod"
>            table="META_METHOD" >
>         <id name="id" column="ID" length="40" type="long">
>             <generator class="assigned" />
>         </id>
>         <properties name="theKey" unique="true">
>             <property name="code" column="CODE" not-null="true"/>
>             <property name="bc" column="BCN_CODE" not-null="true" />
>         </properties>
>         <property name="name" column="NAME" />
>         <list name="parameters" cascade="all-delete-orphan">
>             <key  property-ref="theKey" not-null="true" update="false">
>                 <column name="BFN_CODE" not-null="true"/>
>                 <column name="BCN_CODE" not-null="true"/>
>             </key>
>             <list-index column="SEQUENCE_NUMBER" />
>             <one-to-many class="com.stinscoman.kernel.api.meta.MetaParameter"/>
>         </list>
>     </class>
>  <class name="com.stinscoman.kernel.api.meta.MetaParameter"
>            table="SK_BFN_ARGUMENT">
>         <id name="id" column="ID" length="40" type="long">
>             <generator class="assigned"/>
>         </id>        
>         
>     </class>
> Now, somewhere in hibernate session, i try to put a parameter to method  
> MetaMethod method = ... <the code to obtain MetaMethod object>
> MetaParameter param = ... <the code to obtain MetaParameter object>
> method.getParameters().add(  param  );
> Ok. When session is flushing i always have:
> Caused by: org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of com.stinscoman.kernel.api.meta.MetaMethod.code
> 	at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:171)
> 	at org.hibernate.tuple.component.AbstractComponentTuplizer.getPropertyValue(AbstractComponentTuplizer.java:64)
> 	at org.hibernate.tuple.component.AbstractComponentTuplizer.getPropertyValues(AbstractComponentTuplizer.java:70)
> 	at org.hibernate.tuple.component.PojoComponentTuplizer.getPropertyValues(PojoComponentTuplizer.java:83)
> 	at org.hibernate.type.ComponentType.getPropertyValues(ComponentType.java:353)
> 	at org.hibernate.type.ComponentType.getPropertyValues(ComponentType.java:348)
> 	at org.hibernate.engine.ForeignKeys$Nullifier.nullifyTransientReferences(ForeignKeys.java:77)
> 	at org.hibernate.engine.ForeignKeys$Nullifier.nullifyTransientReferences(ForeignKeys.java:47)
> 	at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:282)
> 	...
> Caused by: java.lang.IllegalArgumentException: java.lang.ClassCastException at 75a0c6
> 	at sun.reflect.GeneratedMethodAccessor79.invoke(Unknown Source)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:597)
> 	at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:145)
> 	... 70 more
> As i understand, the problem is in  property-ref and not-null="true" simultaneously in collection <key> element.

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