[Hibernate-JIRA] Closed: (HHH-929) cascading in wrong order
by Steve Ebersole (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-929?page=co... ]
Steve Ebersole closed HHH-929.
------------------------------
Closing stale resolved issues
> cascading in wrong order
> ------------------------
>
> Key: HHH-929
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-929
> Project: Hibernate Core
> Issue Type: Bug
> Components: core
> Affects Versions: 3.1 beta 2
> Environment: SQL SERVER
> Reporter: Martin Zdila
> Priority: Minor
>
> Hello
> See the mappings at the end of this post. In short: BusinessCase hasTable and Widgets. Widget has WidgetType. WidgetType can have TableColumn. TableColumn has reference to Table.
> I use database with constrained relations so the order of deleting / saving / updating is important.
> CASE 1 with session.delete(businessCase) or CASE 2 with session.saveOrUpdate(businessCase) causes JDBC Exception:
> org.hibernate.PropertyValueException: not-null property references a null or transient value: com.kovine.kfe.dao.TableColumn.table
> at org.hibernate.engine.Nullability.checkNullability(Nullability.java:72)
> There seems to be a problem with cascading order. I was a bit suprised the order of XML entities in hbm cares.
> In CASE 1 there helps deleting all Widgets (which use WidgetType with TableColumn) before BusinessCase.
> In CASE 2 there helps flushing new BusinessCase before adding new Widgets (which use WidgetType with TableColumn).
> PS: I have no time to provide any testcase :-/
> Here are the mappings:
> <hibernate-mapping package="com.kovine.kfe.dao">
> <class name="BusinessCaseImpl" table="KFE_BUSINESS_CASE" abstract="true" proxy="BusinessCase">
> ...
> <!-- auxiliary relation -->
> CASE 1 --> <one-to-one name="table" property-ref="businessCase" cascade="all" constrained="false" />
> <bag name="widgets" table="KFE_WIDGET" order-by="SORT_ORDER" inverse="true" cascade="all">
> <key column="BUSINESS_CASE_ID" />
> <one-to-many class="WidgetImpl" />
> </bag>
> <!-- auxiliary relation -->
> CASE 2 --> <one-to-one name="table" property-ref="businessCase" cascade="all" constrained="false" />
> ...
>
> <joined-subclass table="KFE_BUSINESS_CASE_SINGLE" name="BusinessCaseSingleImpl" proxy="BusinessCaseSingle">
> ...
> </joined-subclass>
> <joined-subclass table="KFE_BUSINESS_CASE_TABLE" name="BusinessCaseTableImpl" proxy="BusinessCaseTable">
> ...
> </joined-subclass>
> </class>
> </hibernate-mapping>
> <hibernate-mapping>
> <class name="com.kovine.kfe.dao.Table" table="KFE_TABLE">
> ...
> <many-to-one unique="true" class="com.kovine.kfe.dao.BusinessCaseImpl" name="businessCase" column="BUSINESS_CASE_ID" not-null="true" embed-xml="false" node="@refId" />
>
> ...
> </class>
> </hibernate-mapping>
> <hibernate-mapping>
> <class name="com.kovine.kfe.dao.WidgetImpl" proxy="com.kovine.kfe.dao.Widget" table="KFE_WIDGET" abstract="true">
> ...
> <one-to-one name="widgetType" class="com.kovine.kfe.dao.WidgetType" cascade="all" />
>
> <many-to-one class="com.kovine.kfe.dao.BusinessCaseImpl" name="businessCase" column="BUSINESS_CASE_ID" not-null="true" embed-xml="false" node="@refId" />
>
> <joined-subclass name="com.kovine.kfe.dao.WidgetForSingleImpl" proxy="com.kovine.kfe.dao.WidgetForSingle" table="KFE_WIDGET_FOR_SINGLE">
> ...
> </joined-subclass>
> <joined-subclass name="com.kovine.kfe.dao.WidgetForTableImpl" proxy="com.kovine.kfe.dao.WidgetForTable" table="KFE_WIDGET_FOR_TABLE">
> ...
> </joined-subclass>
> </class>
> </hibernate-mapping>
> <hibernate-mapping package="com.kovine.kfe.dao">
> <class name="WidgetType" table="KFE_WIDGET_TYPE_ABSTRACT" abstract="true" lazy="false">
> ...
> <one-to-one name="widget" class="WidgetImpl" constrained="true" embed-xml="false" node="@refId" />
>
> <joined-subclass name="WidgetTypePicture" table="KFE_WIDGET_TYPE_PICTURE" lazy="false">
> ...
> </joined-subclass>
> ...
> <joined-subclass name="WidgetTypeUsingColumn" table="KFE_WIDGET_TYPE_USING_COLUMN" abstract="true" lazy="false">
> <key column="WIDGET_ID" />
> <many-to-one unique="true" name="tableColumn" class="TableColumn" cascade="all" column="TABLE_COLUMN_ID" not-null="true" />
> ...
> <joined-subclass name="WidgetTypeText" table="KFE_WIDGET_TYPE_INPUTTEXT" lazy="false">
> ...
> </joined-subclass>
> ...
> </joined-subclass>
> </class>
> </hibernate-mapping>
--
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....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
15 years
[Hibernate-JIRA] Closed: (HHH-1667) I'd like hibernate to support SQL Server like "user defined types"
by Steve Ebersole (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1667?page=c... ]
Steve Ebersole closed HHH-1667.
-------------------------------
Closing stale resolved issues
> I'd like hibernate to support SQL Server like "user defined types"
> ------------------------------------------------------------------
>
> Key: HHH-1667
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1667
> Project: Hibernate Core
> Issue Type: New Feature
> Components: core
> Affects Versions: 3.2.0.cr2
> Environment: N/A
> Reporter: Mark Roulo
>
> SQL Server allows the creation of user defined types.
> These allow (I think ... I've never used SQL server) a user
> to define a new type (much like C typedef) that:
> a) Has an underlying type (e.g. Number, Text, ...) and
> b) Constraints (must be in range 0 to 100)
> The schema can then use this user defined type where
> it normally would require copy-and-paste of the type and
> the constraints.
> It seems that hibernate could easily add this capability even
> to databases that don't support it because the SQL generation
> could perform the copy-and-paste itself.
> The benefits seem pretty obvious:
> a) A type can be changed in one spot, if necessary
> b) The 'same' types become obvious ... all ints aren't
> the same 'type' anymore ... which helps with
> comprehension of the schema (which joins make sense ...)
> c) The constraints that *should* be the same, *ARE* the same.
> This helps with consistency.
--
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....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
15 years
[Hibernate-JIRA] Closed: (HHH-1016) Defining joined-subclass in separate mapping file requires abstract parent to have a discriminator-value
by Steve Ebersole (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1016?page=c... ]
Steve Ebersole closed HHH-1016.
-------------------------------
Closing stale resolved issues
> Defining joined-subclass in separate mapping file requires abstract parent to have a discriminator-value
> --------------------------------------------------------------------------------------------------------
>
> Key: HHH-1016
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1016
> Project: Hibernate Core
> Issue Type: Bug
> Affects Versions: 3.0 final
> Environment: Hibernate 3.0, MySQL 4.0.23-nt, Spring 1.2.3
> Reporter: Josh Landin
> Priority: Minor
>
> The documentation section 6.1.15 states that "It is possible to define subclass, union-subclass, and joined-subclass mappings in separate mapping documents, directly beneath hibernate-mapping".
> When including a joined-subclass within the class element that it extends, a discriminator-value is not required for the abstract parent class. However, when the joined-subclass is moved into its own mapping file, the parent class element's default discriminator-value (classname) is used and consequently fails the cast to a non-string.
> File Parent.hbm.xml:
> <hibernate-mapping>
> <class name="com.foo.AbstractParent" table="parent" abstract="true" lazy="false">
> <id name="id" type="java.lang.Long" column="entityId" unsaved-value="null"><generator class="native" /></id>
> <discriminator column="type" type="java.lang.Integer" not-null="true"/>
> <property name="name" type="java.lang.String" column="name" not-null="true" unique="true" length="100"/>
> </class>
> </hibernate-mapping>
> File Child.hbm.xml:
> <hibernate-mapping>
> <joined-subclass name="com.foo.Child" extends="com.foo.AbstractParent" table="child">
> <key column="childId"/>
> <property name="status"/>
> </joined-subclass>
> </hibernate-mapping>
> File appctx_SessionFactory.xml (Spring):
> <beans>
> <alias alias="sessionFactory" name="org.hibernate.SessionFactory"/>
> <bean id="org.hibernate.SessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
> <property name="mappingResources">
> <list>
> <value>/com/foo/Parent.hbm.xml</value>
> <value>/com/foo/Child.hbm.xml</value>
> </list>
> </property>
> <property name="hibernateProperties">
> <props>
> <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
> <prop key="hibernate.show_sql">true</prop>
> <prop key="hibernate.cglib.use_reflection_optimizer">false</prop>
> <prop key="hibernate.jdbc.batch_size">0</prop>
> </props>
> </property>
> <property name="dataSource">
> <ref bean="javax.sql.DataSource"/>
> </property>
> </bean>
> </beans>
> Causes the following when loading the mappings upon retrieving the sessionFactory from the Spring context:
> Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.hibernate.SessionFactory' defined in file [C:\dev\foo\classes\com\foo\common\app\resources\appctx_SessionFactory.xml]: Initialization of bean failed; nested exception is org.hibernate.MappingException: Could not format discriminator value to SQL string
> at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:355)
> at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:226)
> at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147)
> at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:269)
> at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:317)
> at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:80)
> at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:65)
> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
> at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
> at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
> at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
> at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:100)
> ... 29 more
> Caused by: org.hibernate.MappingException: Could not format discriminator value to SQL string
> at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:273)
> at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
> at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:211)
> at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1005)
> at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:767)
> at org.springframework.orm.hibernate3.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:693)
> at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1003)
> at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:348)
> ... 40 more
> Caused by: java.lang.NumberFormatException: For input string: "com.foo.AbstractParent"
> at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
> at java.lang.Integer.parseInt(Integer.java:468)
> at java.lang.Integer.<init>(Integer.java:609)
> at org.hibernate.type.IntegerType.stringToObject(IntegerType.java:53)
> at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:266)
> ... 47 more
> )
> It seems like having (1) The parent class itself defined as abstract, and (2) The parent class mapping defined as abstract, would cause the discriminator-value to be unused.
> --
> Josh
--
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....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
15 years