-->
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.  [ 2 posts ] 
Author Message
 Post subject: Why Criteria throw an exception?
PostPosted: Thu Aug 04, 2005 2:47 am 
Newbie

Joined: Thu Aug 04, 2005 2:18 am
Posts: 1
I have two table like this :
CREATE TABLE `bet_game` (
`gameId` int(6) unsigned NOT NULL auto_increment,
`subjectcode` varchar(25) NOT NULL default '',
`year` varchar(4) default NULL,
`month` varchar(4) default NULL,
`day` varchar(4) default NULL,
`active` int(1) default NULL,
`gamename` varchar(50) NOT NULL default '',
`winnerid` varchar(6) default NULL,
PRIMARY KEY (`gameId`)
) TYPE=MyISAM;;

CREATE TABLE `bet_subject` (
`Subjectid` int(10) unsigned NOT NULL auto_increment,
`SubjectCode` varchar(25) NOT NULL default '',
`Subjectname` varchar(50) default '0',
`Parentid` int(10) unsigned default '0',
`orderid` int(10) unsigned default '0',
`IsLastLevel` int(1) default NULL,
PRIMARY KEY (`Subjectid`)
) TYPE=MyISAM;;
each subject has many games.Now I create a class:
public class BetGame {
private java.lang.Integer gameid;
......
private BetSubject betSubject = null;
......
}
public class BetSubject {
private java.lang.Integer subjectid;
......
}
In file BetGame.hbm.xml:
<many-to-one name="betSubject" column="subjectcode"
class="betting.db.BetSubject"/>

At last I code like this:
Criteria critSub = session.createCriteria(BetSubject.class);
critSub.add(Expression.eq("subjectcode", subjectCode));
BetSubject subject = (BetSubject) critSub.list().get(0);

Criteria crit = session.createCriteria(BetGame.class);
crit.add(Expression.eq("betSubject", subject));

List cats = crit.list();
there throw an exception.Where a made mistake?3Q


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 04, 2005 5:24 am 
Beginner
Beginner

Joined: Wed Jun 08, 2005 10:01 am
Posts: 22
Location: Italy
Hi !

what kind of exception does it throw ?
Please post it.

Bye
Nic


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

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.