-->
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: Error Help me
PostPosted: Wed Oct 04, 2006 12:26 pm 
Newbie

Joined: Wed Oct 04, 2006 12:22 pm
Posts: 2
Need help with Hibernate?

The Error....


Hibernate operation: could not insert: [com.promainsur.sigepweb.model.Provincia]; uncategorized SQLException for SQL [insert into provincias (nombre, idMatriz, idProvincia) values (?, ?, ?)]; SQL state [HY000]; error code [1364]; Field 'idPais' doesn't have a default value; nested exception is java.sql.SQLException: Field 'idPais' doesn't have a default value


Please help me....


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 04, 2006 12:38 pm 
Senior
Senior

Joined: Wed Aug 17, 2005 12:56 pm
Posts: 136
Location: Erie, PA (USA)
Looks to me as if the table contains a column that is not included in your Hibernate mapping AND the column does not have a default value.

More information would help -- follow the posting instructions.

Curtis ...

_________________
---- Don't forget to rate! ----


Top
 Profile  
 
 Post subject: tablas
PostPosted: Wed Oct 04, 2006 12:45 pm 
Newbie

Joined: Wed Oct 04, 2006 12:22 pm
Posts: 2
Table Mapping

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<class
name="com.promainsur.sigepweb.model.Provincia"
table="provincias"
select-before-update="false"
dynamic-update="false"
dynamic-insert="false"
optimistic-lock="version"
>
<id
name="idprovincia"
column="idProvincia"
type="java.lang.Long"
>
<generator class="increment">
</generator>
</id>
<property
name="nombre"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="nombre"
length="50"
not-null="true"
unique="false"
/>
<!-- imported bi-directional many-to-one association to Pais -->

<many-to-one
name="Pais"
class="com.promainsur.sigepweb.model.Pais"
not-null="false"
update="true"
insert="true"
outer-join="auto"
>
<column name="idPais" />
</many-to-one>

<!-- imported bi-directional many-to-one association to Matriz -->
<many-to-one
name="Matriz"
class="com.promainsur.sigepweb.model.Matriz"
not-null="false"
update="true"
insert="true"
outer-join="auto"
>
<column name="idMatriz" />
</many-to-one>
</class>
</hibernate-mapping>

*************************************************************************************************************************
The Table Class


package com.promainsur.sigepweb.model;

/*
* Created on Tue Sep 12 21:14:02 CEST 2006
*
*/
import java.io.Serializable;
import com.promainsur.sigepweb.model.Provincia;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.EqualsBuilder;

/**
* Provincias Base Java Bean
*
* This class is the base class for the model
*
* <p>
* <a href="Provincia.java.html"><i>View Source</i></a>
* </p>
*
*/

public class Provincia extends com.promainsur.sigepweb.model.BaseObject implements Serializable {

protected Long idprovincia;
protected String nombre;
protected com.promainsur.sigepweb.model.Pais pais;
protected com.promainsur.sigepweb.model.Matriz matriz;

protected java.util.Set escrituraList = new java.util.HashSet();
protected java.util.Set localidadList = new java.util.HashSet();

/**
*
* Default Empty Constructor for class Provincias
*
*/
public Provincia () {
super();
}

/**
*
* Default All Fields Constructor for class Provincias
*
*/
public Provincia (
Long in_idprovincia
,String in_idmatriz
,Long in_idpais
,String in_nombre
) {
this.setIdprovincia(in_idprovincia);
this.setIdmatriz(in_idmatriz);
this.setIdpais(in_idpais);
this.setNombre(in_nombre);
}


public com.promainsur.sigepweb.model.Pais getPais () {
// instantiate a new association entity if it is null
if (pais == null) {
pais = new com.promainsur.sigepweb.model.Pais ();
}
return pais;
}

public void setPais (com.promainsur.sigepweb.model.Pais in_pais) {
this.pais = in_pais;
}

public com.promainsur.sigepweb.model.Matriz getMatriz () {
// instantiate a new association entity if it is null
if (matriz == null) {
matriz = new com.promainsur.sigepweb.model.Matriz ();
}
return matriz;
}

public void setMatriz (com.promainsur.sigepweb.model.Matriz in_matriz) {
this.matriz = in_matriz;
}

public java.util.Set getEscrituraList () {
return escrituraList;
}

public void setEscrituraList (java.util.Set in_escrituraList) {
this.escrituraList = in_escrituraList;
}

public java.util.Set getLocalidadList () {
return localidadList;
}

public void setLocalidadList (java.util.Set in_localidadList) {
this.localidadList = in_localidadList;
}

/**
*
* @return Long
*/
public Long getIdprovincia() {
return this.idprovincia;
}

/**
* Set the idprovincia
*/
public void setIdprovincia(Long aValue) {
this.idprovincia = aValue;
}
/**
*
* @return String
*/
public String getIdmatriz() {
return this.getMatriz().getIdmatriz();
}

/**
* Set the idmatriz
*/
public void setIdmatriz(String aValue) {
this.getMatriz().setIdmatriz(aValue);
}
/**
*
* @return Long
*/
public Long getIdpais() {
return this.getPais().getIdpais();
}

/**
* Set the idpais
*/
public void setIdpais(Long aValue) {
this.getPais().setIdpais(aValue);
}
/**
*
* @return String
*/
public String getNombre() {
return this.nombre;
}

/**
* Set the nombre
*/
public void setNombre(String aValue) {
this.nombre = aValue;
}
/**
* @see java.lang.Object#equals(Object)
*/
public boolean equals(Object object) {
if (!(object instanceof Provincia)) {
return false;
}
Provincia rhs = (Provincia) object;
return new EqualsBuilder()
.append(this.idprovincia, rhs.idprovincia)
.append(this.nombre, rhs.nombre)
.isEquals();
}
/**
* @see java.lang.Object#hashCode()
*/
public int hashCode() {
return new HashCodeBuilder(-82280557, -700257973)
.append(this.idprovincia)
.append(this.nombre)
.toHashCode();
}
/**
* @see java.lang.Object#toString()
*/
public String toString() {
return new ToStringBuilder(this)
.append("idprovincia", this.idprovincia)
.append("nombre", this.nombre)
.toString();
}

/**
* Return the name of the first key column
*/
public String getFirstKeyColumnName() {
return "idprovincia";
}

}


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.