-->
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.  [ 3 posts ] 
Author Message
 Post subject: Set always coming back null
PostPosted: Thu Aug 31, 2006 12:51 pm 
Newbie

Joined: Fri May 12, 2006 3:39 pm
Posts: 13
Howdy everyone,

I am not sure why this is causing me problems... but for some reason, no matter what, my "PrizeSet" is always coming back as an empty set... It's seriously getting to me as I've been messing around with it for a while... Here is a bunch of info..

I didn't actually make these classes, but the guy that did is no longer working here... I don't think he ever actually got it working... I think he just conceptualized the mess...

Onto the code:

Java Classes:

Contest


package com.adsmack.framework.domain;

import java.util.*;

import com.adsmack.framework.domain.Affiliate;

public class Contest {

private int contestID;
private Date startDateTime;
//private Time startTime;
private Date endDateTime;
//private Time endTime;
private String name;
private String description;
private String affiliateID;

private Affiliate affiliate;

public Set prizeSet = new TreeSet();

public ContestType contestType;
//public Company company; TODO implement company

public Contest(){}

public Contest( Date startDT, Date endDT, String nm, String desc, ContestType type )
{
startDateTime = startDT;
endDateTime = endDT;
name = nm;
description = desc;
contestType = type;
}

public int getContestID()
{
return contestID;
}

public void setContestID(int id)
{
contestID = id;
}

public Date getStartDateTime()
{
return startDateTime;
}

public void setStartDateTime(Date dateTime)
{
startDateTime = dateTime;
}

public Date getEndDateTime()
{
return endDateTime;
}

public void setEndDateTime(Date dateTime)
{
endDateTime = dateTime;
}

public String getName()
{
return name;
}

public void setContestType(ContestType type)
{
contestType = type;
}

public ContestType getContestType()
{
return contestType;
}

public void setDescription(String newDesc)
{
description = newDesc;
}

public void setName(String newName)
{
name = newName;
}

public String getDescription()
{
return description;
}

public Set getPrizeSet(){
return prizeSet;
}

public void setPrizeSet (Set prizes){
prizeSet = prizes;
}

/**
* <p>Does ...</p>
*
*
* @return
*/
public ContestPlay play() {
// your code here
return null;
}

public Affiliate getAffiliate() {
return affiliate;
}

public void setAffiliate(Affiliate affiliate) {
this.affiliate = affiliate;
}

public String getAffiliateID() {
return affiliateID;
}

public void setAffiliateID(String affiliateID) {
this.affiliateID = affiliateID;
}

}

Prize

package com.adsmack.framework.domain;

import java.util.Date;

public class Prize {

private int id;
private String shortDescription;
private String longDescription;
private float estimatedValue;
private Date giveAwayStartDateTime;
private Date giveAwayEndDateTime;
private String image;
private PrizeType prizeType;
private Contest contest;

public Prize(){}

public Prize(String shortDesc, String longDesc, float estVal, String img, Date startDate, Date endDate, PrizeType pt, Contest c)
{
shortDescription = shortDesc;
longDescription = longDesc;
estimatedValue = estVal;
giveAwayStartDateTime = startDate;
giveAwayEndDateTime = endDate;
image = img;
prizeType = pt;
contest = c;
}

public int getId()
{
return id;
}

public void setId(int newId)
{
id = newId;
}

public String getShortDescription()
{
return shortDescription;
}

public void setShortDescription(String shortDesc)
{
shortDescription = shortDesc;
}

public String getLongDescription()
{
return longDescription;
}

public void setLongDescription(String longDesc)
{
longDescription = longDesc;
}

public float getEstimatedValue()
{
return estimatedValue;
}

public void setEstimatedValue(float newVal)
{
estimatedValue = newVal;
}

public Date getGiveAwayStartDateTime()
{
return giveAwayStartDateTime;
}

public void setGiveAwayStartDateTime(Date date)
{
giveAwayStartDateTime = date;
}

public Date getGiveAwayEndDateTime()
{
return giveAwayEndDateTime;
}

public void setGiveAwayEndDateTime(Date date)
{
giveAwayEndDateTime = date;
}

public String getImage()
{
return image;
}

public void setImage(String newImg)
{
image = newImg;
}

public PrizeType getPrizeType()
{
return prizeType;
}

public void setPrizeType(PrizeType pt)
{
prizeType = pt;
}

public Contest getContest()
{
return contest;
}

public void setContest(Contest c)
{
contest = c;
}

}


Hibernate version: 3.1

Mapping documents:

Contest:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.adsmack.framework.domain" default-lazy='false'>

<class name="Contest" table = "contest">

<id name="contestID" type="integer">
<column name="contestID" />
<generator class="increment"/>
</id>

<property name="startDateTime" type="date"/>
<property name="endDateTime" type="date"/>

<property name="name" type="string"/>
<property name="description" type="string"/>

<!--<property name="affiliateID" type="integer"/>-->
<!-- <many-to-one name="affiliateID" column="affiliateID" unique="true" /> -->

<property name="affiliateID" />

<!--<property name="advertiserID" type="integer"/>-->

<many-to-one name="contestType" class="ContestType" >
<column name="contestTypeID" />
</many-to-one>

<set name="prizeSet" table="prize">
<key column="prizeID" />
<one-to-many class="Prize" />
</set>

</class>

</hibernate-mapping>

Prize

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.adsmack.framework.domain" default-lazy='false'>

<class name="Prize" table = "prize">
<id name="id" column="prizeID" type="integer">
<generator class="increment"/>
</id>

<property name="shortDescription" type="string"/>
<property name="longDescription" type="string"/>

<property name="estimatedValue" type="float"/>
<property name="image" type="string"/>

<property name="giveAwayStartDateTime" type="date"/>
<property name="giveAwayEndDateTime" type="date"/>

<many-to-one name = "contest" class = "Contest" column = "contestID"/>

<many-to-one name="prizeType" class="PrizeType" >
<column name="prizeTypeID" not-null="true" />
</many-to-one>

</class>

</hibernate-mapping>

Name and version of the database you are using: MySQL 5.0

The generated SQL (show_sql=true):

CREATE TABLE `adsmack`.`contest` (
`contestID` int(10) unsigned NOT NULL default '0',
`startDateTime` datetime NOT NULL default '0000-00-00 00:00:00',
`endDateTime` datetime NOT NULL default '0000-00-00 00:00:00',
`name` varchar(45) NOT NULL default '',
`description` text NOT NULL,
`affiliateID` varchar(50) NOT NULL default '0',
`advertiserID` int(10) unsigned NOT NULL default '0',
`contestTypeID` int(10) unsigned NOT NULL default '0',
PRIMARY KEY (`contestID`),
KEY `FK_ContestContestType` (`contestTypeID`),
CONSTRAINT `FK_ContestContestType` FOREIGN KEY (`contestTypeID`) REFERENCES `contesttype` (`contestTypeID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE `adsmack`.`prize` (
`prizeID` int(10) unsigned NOT NULL auto_increment,
`shortDescription` varchar(100) NOT NULL default '',
`longDescription` text NOT NULL,
`estimatedValue` float NOT NULL default '0',
`image` varchar(150) NOT NULL default '',
`giveAwayStartDateTime` datetime NOT NULL default '0000-00-00 00:00:00',
`giveAwayEndDateTime` datetime NOT NULL default '0000-00-00 00:00:00',
`prizeTypeID` int(10) unsigned NOT NULL default '0',
`contestID` int(10) unsigned NOT NULL default '0',
PRIMARY KEY (`prizeID`),
KEY `FK_PrizeTypeID` (`prizeTypeID`),
KEY `FK_Contest` (`contestID`),
CONSTRAINT `FK_Contest` FOREIGN KEY (`contestID`) REFERENCES `contest` (`contestID`),
CONSTRAINT `FK_PrizeTypeID` FOREIGN KEY (`prizeTypeID`) REFERENCES `prizetype` (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 31, 2006 2:18 pm 
Newbie

Joined: Fri May 12, 2006 3:39 pm
Posts: 13
One problem I just foudn was that the guy was actually using Date objects... I've changed them all to Calendar... but I am still not getting any results... any ideas?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 01, 2006 1:57 am 
Beginner
Beginner

Joined: Mon Nov 22, 2004 11:21 am
Posts: 42
I'm not sure, but maybe it's because of the line:
Code:
public Set prizeSet = new TreeSet();

Change it to:
Code:
private Set prizeSet;

and give it a try.

_________________
Real programmers confuse Halloween and Christmas because OCT 31 = DEC 25


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.