• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Firebird - Hibernate - Not Null

 
Kevin Hamid
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am doing a basic save into a firebird db table. All of my varchar fields are defined as not-null.

I have mapped my pojo class, giving the correct parameter types as not-null.

When I create my pojo, and just try and save, without setting any varchar/string field values, I expect the save to fail, however, when I inspect the db, I see a new record inserted with all the varchar values inserted with a space?

I have tried searching on hibernate.org forums, and looked through the documentation, but I dont think I am missing anything.

Any info would be appreciated.

Ta.
 
Harathi Rao
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Probably your pojo class has default values for its variables. Ifnot give list your pojo class.
 
Kevin Hamid
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry,

Should have sent this earlier, I just instaciate the Cp pojo first of all, I havent initialised any values in the constructor and the hibernate mapping seems ok.





<class name="Cp" table="CP">
<id name="cpNo" column="CP_NO" type="integer">
<generator class="sequence">
<param name="sequence">CPTABLECP_NO</param>
</generator>
</id>

<property name="userId" column="USER_ID" type="string" not-null="true" />
<property name="userPassword" column="USER_PASSWORD" type="string" not-null="true" />
<property name="userEmail" column="USER_EMAIL" type="string" not-null="true" />
<property name="subscriptionDate" column="SUBSCRIPTION_DATE" type="date" not-null="true" />
<property name="subscriptionType" column="SUBSCRIPTION_TYPE" type="integer" not-null="true" />
<property name="subscriptionStatus" column="SUBSCRIPTION_STATUS" type="integer" not-null="true" />
</class>






public abstract class AbstractCp
implements Serializable
{
/** The cached hash code value for this instance. Settting to 0 triggers re-calculation. */
private int hashValue = 0;

/** The composite primary key value. */
private java.lang.Integer cpNo;

/** The value of the simple userId property. */
private java.lang.String userId;

/** The value of the simple userPassword property. */
private java.lang.String userPassword;

/** The value of the simple userEmail property. */
private java.lang.String userEmail;

/** The value of the simple subscriptionDate property. */
private java.util.Date subscriptionDate;

/** The value of the simple subscriptionType property. */
private java.lang.Integer subscriptionType;

/** The value of the simple subscriptionStatus property. */
private java.lang.Integer subscriptionStatus;

/**
* Simple constructor of AbstractCp instances.
*/
public AbstractCp()
{
}

/**
* Constructor of AbstractCp instances given a simple primary key.
* @param cpNo
*/
public AbstractCp(java.lang.Integer cpNo)
{
this.setCpNo(cpNo);
}

/**
* Return the simple primary key value that identifies this object.
* @return java.lang.Integer
*/
public java.lang.Integer getCpNo()
{
return cpNo;
}

/**
* Set the simple primary key value that identifies this object.
* @param cpNo
*/
public void setCpNo(java.lang.Integer cpNo)
{
this.hashValue = 0;
this.cpNo = cpNo;
}

/**
* Return the value of the USER_ID column.
* @return java.lang.String
*/
public java.lang.String getUserId()
{
return this.userId;
}

/**
* Set the value of the USER_ID column.
* @param userId
*/
public void setUserId(java.lang.String userId)
{
this.userId = userId;
}

/**
* Return the value of the USER_PASSWORD column.
* @return java.lang.String
*/
public java.lang.String getUserPassword()
{
return this.userPassword;
}

/**
* Set the value of the USER_PASSWORD column.
* @param userPassword
*/
public void setUserPassword(java.lang.String userPassword)
{
this.userPassword = userPassword;
}

/**
* Return the value of the USER_EMAIL column.
* @return java.lang.String
*/
public java.lang.String getUserEmail()
{
return this.userEmail;
}

/**
* Set the value of the USER_EMAIL column.
* @param userEmail
*/
public void setUserEmail(java.lang.String userEmail)
{
this.userEmail = userEmail;
}

/**
* Return the value of the SUBSCRIPTION_DATE column.
* @return java.util.Date
*/
public java.util.Date getSubscriptionDate()
{
return this.subscriptionDate;
}

/**
* Set the value of the SUBSCRIPTION_DATE column.
* @param subscriptionDate
*/
public void setSubscriptionDate(java.util.Date subscriptionDate)
{
this.subscriptionDate = subscriptionDate;
}

/**
* Return the value of the SUBSCRIPTION_TYPE column.
* @return java.lang.Integer
*/
public java.lang.Integer getSubscriptionType()
{
return this.subscriptionType;
}

/**
* Set the value of the SUBSCRIPTION_TYPE column.
* @param subscriptionType
*/
public void setSubscriptionType(java.lang.Integer subscriptionType)
{
this.subscriptionType = subscriptionType;
}

/**
* Return the value of the SUBSCRIPTION_STATUS column.
* @return java.lang.Integer
*/
public java.lang.Integer getSubscriptionStatus()
{
return this.subscriptionStatus;
}

/**
* Set the value of the SUBSCRIPTION_STATUS column.
* @param subscriptionStatus
*/
public void setSubscriptionStatus(java.lang.Integer subscriptionStatus)
{
this.subscriptionStatus = subscriptionStatus;
}

/**
* Implementation of the equals comparison on the basis of equality of the primary key values.
* @param rhs
* @return boolean
*/
public boolean equals(Object rhs)
{
if (rhs == null)
return false;
if (! (rhs instanceof Cp))
return false;
Cp that = (Cp) rhs;
if (this.getCpNo() == null || that.getCpNo() == null)
return false;
return (this.getCpNo().equals(that.getCpNo()));
}

/**
* Implementation of the hashCode method conforming to the Bloch pattern with
* the exception of array properties (these are very unlikely primary key types).
* @return int
*/
public int hashCode()
{
if (this.hashValue == 0)
{
int result = 17;
int cpNoValue = this.getCpNo() == null ? 0 : this.getCpNo().hashCode();
result = result * 37 + cpNoValue;
this.hashValue = result;
}
return this.hashValue;
}
}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic