Hi all;
I'm using the Criteria API to create a join between two entities:
Code:
[u]1 st entity : [/u]
public class CardHeader
{
..
private Card.CardType card;
..
@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "cardHeader")
private Card card
...
}
[u]2 nd entity [/u]
@Table(name="CARD")
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public abstract class Card {
public enum CardType
{CARD_VISA, CARD_MASTER, CARD_ELECTRON};
@OneToOne(cascade = CascadeType.ALL)
private CardHeader carHeader;
..}
And 3 concrete classes (VisaCard, MasterCard and ElectronCard)..
I create my criteria like this
Code:
Critaria crt = session.CreateCriteria(CardHeader.class)Je voudrais
And i want to retrieve only Visa Card , so i add a join like this (using the ) card refeence in CardHeaderclass:
Code:
crt.CreatCriteria("card");
But this seems to give me all cards..
Is there any way to retrieve , using Criteria API , only one type of card..?
Can i use the "private Card.CardType card" reference to the type of
Card in CardHeader class ?
Thank you by advance!