I am trying to map multiple levels of inheritance via two discriminator columns and dont see a way to do this via the EJB3.0 annotations.
There is a single table,
Code:
authorization
----------------
auth_id int identity
name
description
auth_type_id
auth_action_type_id
the auth_type_id is used to pick the general type of the authorization,
and the auth_action_type_id is used to pick the subclass of that type.
Code:
@Entity
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="auth_type_id",discriminatorType=DiscriminatorType.INTEGER)
public abstract class Authorization {
............
}
@Entity
@DiscriminatorValue("1")
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="auth_action_type_id",discriminatorType=DiscriminatorType.INTEGER)
public abstract class SystemAuthorization extends Authorization {
.............
}
@Entity
@DiscriminatorValue("2")
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="auth_action_type_id",discriminatorType=DiscriminatorType.INTEGER)
public abstract class CustomAuthorization extends Authorization {
...............
}
@Entity
@DiscriminatorValue("15")
public class SystemReadAuthorization extends SystemAuthorization {
...............
}
@Entity
@DiscriminatorValue("16")
public class CustomExecAuthorization extends CustomAuthorization {
...............
}
with mapping like this Hibernate does not complain at all, but ignores completely the second discriminator column.
for the query "from CustomExecAuthorization" what i want is:
Code:
select * from authorization where auth_type_id = 2 and auth_action_type_id = 16
but i get instead:
Code:
select * from authorization where auth_type_id = 16
anyone know what I am doing wrong here?