Hi,
Code:
@Entity
@Table(catalog="lookup",schema="dbo", name = "lookup_table")
@DiscriminatorColumn(
name="tablename",
discriminatorType=DiscriminatorType.STRING
)
public class LookupTable implements ILookup {
/**
* Primary key.
*/
@Id
@Column(name = "codeID")
private Integer id;
...
Code:
@Entity
@DiscriminatorValue("persoon")
public class TypePersoonCode extends LookupTable implements Serializable{
}
With these entity, if i query the database, the discriminator are perfectly working. I get a sql like this :
select ... from lookup.dbo.lookup_table typepersoo0_ where
typepersoo0_.tablename='persoon' and typepersoo0_.codeID=?
It's returning 1 row, ok.
Now in an other entity, i try to add a ManyToOne column to this lookup.
Code:
@Entity
@Table(catalog="params", schema="dbo", name = "paramspersoonbis")
public class ParamsPersoonBis implements Serializable {
@Id
@Column(name="persoonID")
private Integer persoonId;
@ManyToOne
@JoinColumn(name = "typepersooncodeID")
private TypePersoonCode typePersoonCodeId;
...
But when i query the db (with a simple .find(class,id)), the generated sql don't use the discriminatorValue:
Code:
select ... from params.dbo.paramspersoonbis paramspers0_, lookup.dbo.lookup_table typepersoo1_ where paramspers0_.typepersooncodeID *= typepersoo1_.codeID and paramspers0_.persoonID=?
And I receive multiple row exception for the typepersoon table/class,
( if i add manually "and typepersoo0_.tablename='persoon' " it's working. )
Did i forget something, or discriminator don't work with relational class?
(with special record i also try wih onetoon relation)