-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: subclass values not inserting when using DBUnit
PostPosted: Tue Feb 08, 2005 8:14 am 
Newbie

Joined: Thu Dec 02, 2004 6:27 am
Posts: 10
Hi,
I've been using DBUnit very happily to insert data for testing. At the moment it acquires the connection through Hibernate (see bottom) and inserts using it's own tools.

This works for everything except the one table that corresponds to two POJOs (one extends the other) and I can't work out why. It may be entirely a DBUnit issue (in which case I apologise for asking) but I was wondering if anyone else had encountered this obscure problem.

In the below mapping fk_role_id is not inserted from the xml set below that (role is inserted fine previous to this). Could it be because fk_role_id is actually in "virtual" table user_role_access (as opposed to the user_access that DBUnit requests?)

Seems a bit far fetched to me but I am ruling out possibilities...

(normal usage of everything is AOK, this is strictly a DBunit issue)

c



library versions:
Hibernate 2.1.6
DBUnit 2.1
Postgresql 7.4.2

Mapping documents:
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping
>
<class
name="net.sportplan.model.UserAccess"
table="user_access"
discriminator-value="USER"
>

<id
name="id"
column="id"
type="java.lang.Long"
unsaved-value="null"
>
<generator class="increment">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-UserAccess.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>

<discriminator
column="discriminator"
/>

<version
name="version"
type="java.lang.Integer"
column="version"
access="property"
unsaved-value="undefined"
/>

<many-to-one
name="access"
class="net.sportplan.model.Access"
cascade="none"
outer-join="auto"
column="fk_access_id"
not-null="true"
/>

<many-to-one
name="user"
class="net.sportplan.model.User"
cascade="none"
outer-join="auto"
column="fk_user_id"
not-null="true"
/>

<many-to-one
name="invoice"
class="net.sportplan.model.Invoice"
cascade="none"
outer-join="auto"
column="fk_invoice_id"
not-null="true"
/>

<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-UserAccess.xml
containing the additional properties and place it in your merge dir.
-->
<subclass
name="net.sportplan.model.UserRoleAccess"
discriminator-value="ROLE"
>

<many-to-one
name="role"
class="net.sportplan.model.Role"
cascade="none"
outer-join="auto"
column="fk_role_id"
/>

<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-UserRoleAccess.xml
containing the additional properties and place it in your merge dir.
-->

</subclass>

</class>

</hibernate-mapping>

flat data_set.xml
<user_access id="2" discriminator="ROLE" version="0" fk_role_id="1" fk_access_id="2" fk_user_id="1" fk_invoice_id="1" />

TestCase extending DBUnit code
protected IDatabaseConnection getConnection() throws Exception {
DataSource dataSource = (DataSource) ctx
.getBean("dataSource");
return new DatabaseConnection(dataSource.getConnection());
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.