-->
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.  [ 2 posts ] 
Author Message
 Post subject: joined-subclass tries to insert in the parent class' table
PostPosted: Fri Oct 22, 2004 11:48 am 
Beginner
Beginner

Joined: Fri Oct 15, 2004 10:29 am
Posts: 21
Now that I am using the jTDS driver I no longer have the re-read problem that I had with the SQL Server driver. However, I have some unexpected behavior for a joined-subclass. When the joined-subclass object is inserted, hibernate tries to insert it into the parent class' table. As I understand the mapping, the tables are distinct.

Why does it do this? Have I misconfigured? I only want hibernate to persist subclass objects to the subclass table, nowhere else.

Thanks,
Derrick



CREATE TABLE [dbo].[emailTemplate] (
[id] [int] IDENTITY (1, 1) NOT NULL ,
[name] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[description] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[fromAddress] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[toAddresses] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[cc] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[bcc] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[subject] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[body] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[calendarAppointment] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[enabled] [bit] NOT NULL
) ON [PRIMARY]
GO

CREATE TABLE [dbo].[emailMessage] (
[id] [int] IDENTITY (1, 1) NOT NULL ,
[name] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[description] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[fromAddress] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[toAddresses] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[cc] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[bcc] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[subject] [nvarchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[body] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[calendarAppointment] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO

Hibernate version:
2.1.3

Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping package="com.skillsoft.mgs.email">
<class mutable="false" name="EmailTemplateBean" table="emailTemplate">
<id name="ID" column="ID" unsaved-value="0">
<generator class="native"/>
</id>
<property name="name" column="name"/>
<property name="descr" column="description"/>
<property name="from" column="fromAddress"/>
<property name="to" column="toAddresses"/>
<property name="cc" column="cc"/>
<property name="bcc" column="bcc"/>
<property name="subject" column="subject"/>
<property name="body" column="body"/>
<property name="calendarAppointment" column="calendarAppointment"/>
<property name="enabled" column="enabled"/>
<joined-subclass name="com.skillsoft.mgs.email.queued.EmailMessage" table="emailMessage">
<key column="ID"/>
<property name="name" column="name"/>
<property name="descr" column="description"/>
<property name="from" column="fromAddress"/>
<property name="to" column="toAddresses"/>
<property name="cc" column="cc"/>
<property name="bcc" column="bcc"/>
<property name="subject" column="subject"/>
<property name="body" column="body"/>
<property name="calendarAppointment" column="calendarAppointment"/>
</joined-subclass>
</class>
</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:
SQL Server 2000 with jTDS 0.9 driver

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 24, 2004 10:23 am 
Regular
Regular

Joined: Mon Nov 24, 2003 6:36 pm
Posts: 105
Which inheritance strategy are you trying to use? I assume table/subclass, in which case, this mapping doesn't seem to make much sense, as there are many duplicated properties for each class.

Does your email message really extend emailtemplate in your object model?

--James


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

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.