« Return to Thread: Discriminator issue
khaskett wrote:Right before I do the update, I inspected the CpTransaction object using
the debugger and the cpTransCoverage object is
com.gmrc.jpa.domain.CpTransCoverage@77a877a8. In the code prior to
setting it, we first create the object as a new CpCoverage, then before
setting it we create a CpTransCoverage with a constructor call passing
in the CpCoverage and updating all fields with the values from that
object passed in, not retaining the reference to the actual object.
Anything else I should be checking?
-----Original Message-----
From: eclipselink-users-bounces@eclipse.org
[mailto:eclipselink-users-bounces@eclipse.org] On Behalf Of James
Sutherland
Sent: Wednesday, July 08, 2009 9:21 AM
To: eclipselink-users@eclipse.org
Subject: Re: [eclipselink-users] Discriminator issue
It looks like you are persisting a CpCoverage (the superclass) not a
CpTransCoverage in your app somewhere. The class name is the default
indicator, which is what it is getting. You should also set a
DiscriminatorValue on CpCoverage, or make it abstract.
khaskett wrote:
>
> I have a parent / child relationship where the child is a Entity that
> has a Discriminator annotation. Currently we are seeing this error
> show up in the logs. The Discriminator is based off the COVERAGE_TYPE
field.
>
> [7/7/09 17:02:12:207 CDT] 00000041 SystemOut O [EL Fine]:
2009-07-07
> 17:02:12.191--ClientSession(1159218456)--Connection(1268009876)--Threa
> d(Thread[WebContainer
> : 3,5,main])--INSERT INTO CP_COVERAGE (COVERAGE_CODE, BUILDING_NUMBER,
> RATING_ORIGINAL_RATE, PREMIUM_ACTUAL, RATING_MODIFIED_RATE,
> LIABILITY_LIMIT, COVERAGE_TYPE, PREMIUM_MIN, PREMIUM_PREVIOUS_PRO,
> PREMIUM_OVERRIDE, STATE_CODE, SUBCOVERAGE_DESC, FORM_NUMBER, SORT_SEQ,
> LOCATION_NUMBER, COVERAGE_CLASS_CODE, PREMIUM_PREVIOUS,
> PREMIUM_MEET_MIN, RATING_RMF, RATED_COVERAGE_FLAG,
> PREMIUM_OVERRIDE_RESET, COVERAGE_DESC, COV_GROUP, ACTION_CODE,
> BLANKET_ID) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
?, ?, ?, ?, ?, ?, ?, ?)
> bind => [790, 0, 0.0, 4.0, 0.0, null, CpCoverage, 0.0, 0.0,
-1.0,
> null, null, null, 790, 0, null, 0.0, 0.0, 0.0, N, N, Terrorism, null,
> null, null]
> [7/7/09 17:02:14:691 CDT] 00000041 SystemOut O [EL Warning]:
> 2009-07-07
> 17:02:14.519--UnitOfWork(1153582274)--Thread(Thread[WebContainer :
> 3,5,main])--Exception [EclipseLink-4002] (Eclipse Persistence Services
> -
> 1.1.1.v20090430-r4097):
> org.eclipse.persistence.exceptions.DatabaseException
> Internal Exception: java.sql.DataTruncation: Data truncation Error
> Code: 0
> Call: INSERT INTO CP_COVERAGE (COVERAGE_CODE, BUILDING_NUMBER,
> RATING_ORIGINAL_RATE, PREMIUM_ACTUAL, RATING_MODIFIED_RATE,
> LIABILITY_LIMIT, COVERAGE_TYPE, PREMIUM_MIN, PREMIUM_PREVIOUS_PRO,
> PREMIUM_OVERRIDE, STATE_CODE, SUBCOVERAGE_DESC, FORM_NUMBER, SORT_SEQ,
> LOCATION_NUMBER, COVERAGE_CLASS_CODE, PREMIUM_PREVIOUS,
> PREMIUM_MEET_MIN, RATING_RMF, RATED_COVERAGE_FLAG,
> PREMIUM_OVERRIDE_RESET, COVERAGE_DESC, COV_GROUP, ACTION_CODE,
> BLANKET_ID) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
?, ?, ?, ?, ?, ?, ?, ?)
> bind => [790, 0, 0.0, 4.0, 0.0, null, CpCoverage, 0.0, 0.0,
-1.0,
> null, null, null, 790, 0, null, 0.0, 0.0, 0.0, N, N, Terrorism, null,
> null, null]
> Query: InsertObjectQuery(com.gmrc.jpa.domain.CpCoverage@71547154)
>
> The problem seems to be that it is trying to insert CpCoverage value
> instead of the correct value into that field.
>
> We have tried setting the COVERAGE_TYPE field explicitly and leaving
> it blank and get the same result. I have tried a very simple example
> of this and it seems to work fine.
>
> CpTransaction cpTrans = new CpTransaction();
> cpTrans.setTransactionStatus(TransactionStatus.IN_PROGRESS);
> cpTrans.setTransactionType(TransactionType.NEW_BUSINESS);
> cpTrans.setParentTransactionId(0L);
> CpTransCoverage cpTerrorism = new CpTransCoverage();
> cpTerrorism.setCoverageCode("999");
> cpTrans.setCpTerrorismCoverage(cpTerrorism);
>
> cpTransactionManager.save(cpTrans);
>
> Setting only the non-nullable fields and then adding the
CpTransCoverage.
>
> @Entity
> @DiscriminatorValue(value = "P")
> public class CpTransCoverage extends CpCoverage { ...
>
> @Entity
> @Table(name = "CP_COVERAGE")
> @Inheritance(strategy = InheritanceType.SINGLE_TABLE)
> @DiscriminatorColumn(name = "COVERAGE_TYPE", discriminatorType =
> DiscriminatorType.STRING, length = 1) public class CpCoverage extends
> BaseDomain implements java.io.Serializable {
>
> ....
>
> Anything overly obvious I am missing here?
>
« Return to Thread: Discriminator issue
| Free embeddable forum powered by Nabble | Forum Help |