Hallo all. I have this set of classes:
@Entity
@Table(name = "S_MC_CC_RAPPORTI")
@Inheritance(strategy=InheritanceType.JOINED)
@DiscriminatorColumn(name="COD_TIPORAPPORTO",
discriminatorType=DiscriminatorType.CHAR, length=1)
public abstract class Rapporto implements Serializable {
private static final long serialVersionUID = -5567166522882040440L;
@Id
@Column(name = "COD_RAPPORTO")
protected Long codiceRapporto;
And this sublass:
@Entity
@Table(name="S_MC_CC_CCCLIENTI")
@DiscriminatorValue("1 ")
public class ContoCorrente extends Rapporto {
private static final long serialVersionUID = -3380622649760983262L;
@Column(name = "DESC_DIVISA")
private String divisa;
The problem is on the discriminator value: on the table the column is CHAR(2).
When I make the getItemById on the subclass all works fine: this is the generated eclipselink sql: (I replaced the column definition with * for easy to read)
[EL Fine]: 2011-01-16 16:01:14.531--ServerSession(5230193)--Connection(11601738)--Thread(Thread[main,5,main])-- SELECT * FROM S_MC_CC_RAPPORTI t0, S_MC_CC_CCCLIENTI t1 WHERE ((t0.COD_RAPPORTO = ?) AND ((t1.COD_RAPPORTO = t0.COD_RAPPORTO) AND (t0.COD_TIPORAPPORTO = ?)))
bind => [1120676, 1 ]
If I change the @DiscriminatorValue("1")
removing the space the data is not found: this is the relative generated sql
[EL Fine]: 2011-01-16 16:03:46.671--ServerSession(5230193)--Connection(11601738)--Thread(Thread[main,5,main])--SELECT * FROM S_MC_CC_RAPPORTI t0, S_MC_CC_CCCLIENTI t1 WHERE ((t0.COD_RAPPORTO = ?) AND ((t1.COD_RAPPORTO = t0.COD_RAPPORTO) AND (t0.COD_TIPORAPPORTO = ?)))
bind => [1120676, 1]
Note that the two queries work fine with TOAD: both the t0.COD_TIPORAPPORTO = '1 ' one, even the t0.COD_TIPORAPPORTO = '1'.
OK: so I think that the @DiscriminatorValue("1 ")
is correct.
Now I make an association many-to-many with the super class Rapporto as described here
If I mantain the @DiscriminatorValue("1 ")
I get
[EL Warning]: 2011-01-16 16:09:33.421--ServerSession(29839159)--Thread(Thread[main,5,main])--Exception [EclipseLink-43] (Eclipse Persistence Services - 2.1.2.v20101206-r8635): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: Missing class for indicator field value [1] of type [class java.lang.String].
Descriptor: RelationalDescriptor(it.alten.intesasanpaolo.contratto.domain.core.rapporto.Rapporto --> [DatabaseTable(S_MC_CC_RAPPORTI)])
If I change the @DiscriminatorValue("1")
removing the space all work fine but I receive no data (even If the data is present on DB).
I dunno what to do.... Any idea?
Kind regards
Massimo