-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Criteria API : join to abstract classes
PostPosted: Wed Feb 27, 2008 6:16 am 
Newbie

Joined: Wed Feb 27, 2008 6:06 am
Posts: 1
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!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.