-->
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: Exception-inserted value is too large for a column(From Cnu)
PostPosted: Mon May 28, 2007 11:26 am 
Newbie

Joined: Mon May 28, 2007 10:53 am
Posts: 4
i am new to Hibernate

i am using Hibernate3.0

Oracle version is 9i
-------------------------
My Problem Decription
--------------------------
I am getting Exception like "inserted value is too large for a column" even the struct of the table and the properties sizes in the .hbm.file is same

for the reference i am adding the tables structure and .hbm files,action class and jsp(from here i am calling POJO objects)
------------------------
i have created POJO's(ProjectRegionInfo,ProjectPidCostcentre) and respective .hbm files (ProjectRegionInfo.hbm.xml,ProjectPidCostcentre.hbm.xml)
and the tables i have created are PROJECT_PID_REGION,PROJECT_PID_COSTCENTRE and the structure of the tables is like this

SQL> desc PROJECT_PID_REGION
Name Null? Type
----------------------------------------- -------- ---------------
PRO_ID NOT NULL NUMBER(10)
REG_REGION_CODE NOT NULL VARCHAR2(4)
PROJECT_NAME NOT NULL VARCHAR2(255)

SQL> desc PROJECT_PID_COSTCENTRE

PRO_PRO_ID NUMBER(10)
CC_CC_ID NOT NULL NUMBER(10)
CC_COST_CENTRE_CODE NOT NULL VARCHAR2(15)
------------------------------------------
POJO which i created on the tables are
-------------------------------------------------
ProjectRegionInfo
----------------------------------------------------


package com.db.hibernate;

import java.io.Serializable;
import java.util.List;
import org.apache.commons.lang.builder.ToStringBuilder;


/**
* @hibernate.class
* table="PROJECT_PID_REGION"
* *
* @struts:form
* name="ProjectRegionInfo"
* type="com.db.hibernate.ProjectRegionInfo"
*
*/
public class ProjectRegionInfo extends com.db.generic.HibernatePersistent implements Serializable {

/** identifier field */
private Long proId;

/** persistent field */
private String projectName;

/** persistent field */
private String regionCode;

/** persistent field */
private List projectPidCostCentres;

/** default constructor */
public ProjectRegionInfo() {

}

/** full constructor */
public ProjectRegionInfo(String projectName,String regionCode,List projectPidCostCentres) {
this.projectName = projectName;
this.regionCode = regionCode;
this.projectPidCostCentres = projectPidCostCentres;
}


/**
* @hibernate.id
* generator-class="sequence"
* type="java.lang.Long"
* column="PRO_ID"
* @hibernate.generator-param
* name="sequence"
* value="PROJECT_PID_REGIONS_SEQ"
*
*/
public Long getProId() {
return this.proId;
}

public void setProId(Long proId) {
this.proId = proId;
}

/**
* @hibernate.property
* column="PROJECT_NAME"
* length="255"
* not-null="true"
*
*/
public String getProjectName() {
return this.projectName;
}

public void setProjectName(String projectName) {
this.projectName = projectName;
}

/**
* @hibernate.property
* column="REG_REGION_CODE"
* length="4"
* not-null="true"
*
*/
public String getRegionCode() {
return this.projectName + " (" + this.regionCode + ")";
}

public void setRegionCode(String regionCode) {
this.regionCode = regionCode;
}

/**
* @hibernate.bag
* lazy="true"
* inverse="true"
* cascade="none"
* @hibernate.collection-key
* column="PRO_PRO_ID"
* @hibernate.collection-one-to-many
* class="com.db.hibernate.ProjectPidCostCentres"
*
*/
public List getProjectPidCostCentres() {
return this.projectPidCostCentres;
}

public void setProjectPidCostCentres(List projectPidCostCentres) {
this.projectPidCostCentres = projectPidCostCentres;
}


}



--------------------------------------------
ProjectPidCostCentres.java
--------------------------------------------


package com.db.hibernate;

import java.io.Serializable;
import java.util.List;
import org.apache.commons.lang.builder.ToStringBuilder;


/**
* @hibernate.class
* table="PROJECT_PID_COSTCENTRE"
* *
* @struts:form
* name="ProjectPidCostCentres"
* type="com.db.hibernate.ProjectPidCostCentres"
*
*/
public class ProjectPidCostCentre extends com.db.generic.HibernatePersistent implements Serializable {

/** identifier field */
private Long ccId;

/** persistent field */
private String costCentreCode;

/** persistent field */
private com.db.hibernate.ProjectRegionInfo projectRegionInfo;


/** default constructor */
public ProjectPidCostCentre() {
}

/** full constructor */
public ProjectPidCostCentre( Long ccId,String costCentreCode) {
this.ccId = ccId;
this.costCentreCode = costCentreCode;
}

/**
* @hibernate.id
* generator-class="sequence"
* type="java.lang.Long"
* column="CC_CC_ID"
* @hibernate.generator-param
* name="sequence"
* value="ProjectPidCostCentre"
*
*/

public Long getCcId() {
return this.ccId;
}

public void setCcId(Long ccId) {
this.ccId = ccId;
}

/**
* @hibernate.property
* column="CC_COST_CENTRE_CODE"
* length="255"
* not-null="true"
*
*/
public String getCostCentreCode() {
return this.costCentreCode;
}

public void setCostCentreCode(String costCentreCode) {
this.costCentreCode = costCentreCode;
}

/**
* @hibernate.many-to-one
* not-null="true"
* @hibernate.column name="PRO_PRO_ID"
*
*/
public com.db.hibernate.ProjectRegionInfo getProjectRegionInfo() {
return this.projectRegionInfo;
}

public void setProjectRegionInfo(com.db.hibernate.ProjectRegionInfo projectRegionInfo) {
this.projectRegionInfo = projectRegionInfo;
}



}




,and the hbm.files are

-------------------------------------------------------
ProjectRegionInfo.hbm.xml file
-----------------------------------------------------------

<?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>
<!--
Created by the Middlegen Hibernate plugin 2.1 modified by Ben Riley

http://boss.bekk.no/boss/middlegen/
http://www.hibernate.org/
-->

<class
name="com.db.hibernate.ProjectRegionInfo"
table="PROJECT_PID_REGION"
lazy="true"
>
<meta attribute="class-description" inherit="false">
@hibernate.class
table="PROJECT_PID_REGION"

@struts:form
name="ProjectRegionInfo"
type="com.db.hibernate.ProjectRegionInfo"
</meta>
<id
name="proId"
type="java.lang.Long"
column="PRO_ID"
>
<meta attribute="field-description">
@hibernate.id
generator-class="sequence"
type="java.lang.Long"
column="PRO_ID"

@hibernate.generator-param
name="sequence"
value="PROJECT_PID_REGIONS_SEQ"
</meta>
<generator class="sequence">
<param name="sequence">PROJECT_PID_REGIONS_SEQ</param>
</generator>
</id>

<property
name="regionCode"
type="java.lang.String"
column="REG_REGION_CODE"
not-null="true"
length="4"
>
<meta attribute="field-description">
@hibernate.property
column="REG_REGION_CODE"
length="4"
not-null="true"
</meta>
</property>

<property
name="projectName"
type="java.lang.String"
column="PROJECT_NAME"
not-null="true"
length="255"
>
<meta attribute="field-description">
@hibernate.property
column="PROJECT_NAME"
length="255"
not-null="true"
</meta>
</property>

<!-- Associations -->

<bag
name="projectPidCostCentres"
lazy="true"
inverse="true"
cascade="none"
>
<meta attribute="field-description">
@hibernate.bag
lazy="true"
inverse="true"
cascade="none"

@hibernate.collection-key
column="PRO_PRO_ID"

@hibernate.collection-one-to-many
class="com.db.hibernate.ProjectPidCostCentre"
</meta>
<key>
<column name="PRO_PRO_ID" />
</key>
<one-to-many
class="com.db.hibernate.ProjectPidCostCentre"
/>
</bag>

</class>
</hibernate-mapping>

----------------------------------------------------------

ProjectPidCostCentre.hbm.xml
----------------------------------------------------------


<?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>
<!--
Created by the Middlegen Hibernate plugin 2.1 modified by Ben Riley

http://boss.bekk.no/boss/middlegen/
http://www.hibernate.org/
-->

<class
name="com.db.hibernate.ProjectPidCostCentre"
table="PROJECT_PID_COSTCENTRE"
lazy="true"
>
<meta attribute="class-description" inherit="false">
@hibernate.class
table="PROJECT_PID_COSTCENTRE"

@struts:form
name="ProjectPidCostCentre"
type="com.db.hibernate.ProjectPidCostCentre"
</meta>

<id
name="ccId"
type="java.lang.Long"
column="CC_CC_ID"
>
<meta attribute="field-description">
@hibernate.id
generator-class="sequence"
type="java.lang.Long"
column="CC_CC_ID"

@hibernate.generator-param
name="sequence"
value="PROJECT_PID_COST_CENTRES_SEQ"
</meta>
<generator class="sequence">
<param name="sequence">PROJECT_PID_COST_CENTRES_SEQ</param>
</generator>
</id>

<property
name="costCentreCode"
type="java.lang.String"
column="CC_COST_CENTRE_CODE"
length="15"
>
<meta attribute="field-description">
@hibernate.property
column="CC_COST_CENTRE_CODE"
length="15"
</meta>
</property>


<!-- Associations -->

<!-- bi-directional many-to-one association to ProjectRegionInfo -->
<many-to-one
name="ProjectRegionInfo"
class="com.db.hibernate.ProjectRegionInfo"
not-null="true"
>
<meta attribute="field-description">
@hibernate.many-to-one
not-null="true"
@hibernate.column name="PRO_PRO_ID"
</meta>
<column name="PRO_PRO_ID" />
</many-to-one>

</class>
</hibernate-mapping>

-----------------------------------------------------------------------
My Action Class where i worte HQL query on this
-----------------------------------------------------------------------

List projectRegionInfo = Project.query("from ProjectRegionInfo pro where pro.proId in ( select vpa.proId as proId from MvProjectAccessReadWrite vpa where vpa.emailAddress = lower(cnuss@gmail.com));
request.setAttribute("projectRegionInfo", projectRegionInfo);


/*this query is executing successfully,*/
--------------------------------------------------------
Helper class HibernatePersistent.java which is having the query(invoking from ContractAction.java class) method where i am creating the hibernate seesion
------------------------------------------------------

public class HibernatePersistent extends ActionForm implements Persistent{

public HibernatePersistent()
{
}

/**
* run an a query on the persistent store
* @param filter query string
* @param values parameter values
* @securityParam Filter parameter to restrict rows returned by query, i.e. user's email address
* @return collection of results
*/
public static List query(String filter,Object[] values, String securityParam) throws PersistentException
{
try
{
if ( securityParam != null && securityParam.length() > 0 ) {
HibernateSession.currentSession().disableFilter("securityAllFilter");
HibernateSession.currentSession().enableFilter("securityFilter").setParameter("emailAddress", securityParam);
}
Query q=HibernateSession.currentSession().createQuery(filter);
for (int i=0; i<values.length; i++)
{
try
{
long s=Long.parseLong(values[i].toString());
q.setLong(i,s);
}
catch (NumberFormatException ex)
{
q.setString(i,values[i].toString());
}
}
return q.list();
}
catch (HibernateException ex)
{
throw new PersistentException("Problem running query: "+ex.getMessage(),ex);
}
}

}





------------------------------------------------------------------------------------
The jsp where i am trying to featching this pojo obejcts is ContractAdd.jsp(i am pasting specific part of the jsp
----------------------------------------------------------------------------------------------------------------
<tr>
<td>
<layout:select key="head.projectName" property="proId">
<layout:option value=""/>
<layout:options collection="projectRegionInfo" property="proId" labelProperty="regionCode" sourceOf="ccId"/>
</layout:select>
</td>
</tr>
<tr>
<td>
<layout:select key="head.costCentre" property="ccId">
<layout:optionsDependent collection="projectPidCostCentres" property="ccId" dependsFrom="proId" labelProperty="costCentreCode"/>
</layout:select>
</td>
</tr>
<tr>
--------------------------------
PROBLEM is
--------------------------------
when jsp is loading it is successfully loading with all the Combo Boxes with the relevent objects

but on the tomcat server i am seeing one Exception like below

Please help on this soon .............

i have increased the table column sizes in the database but it doesn't help me much, I am seeing the same exception on the console


------------------------------------

update PROJECT_PID_REGION set REG_REGION_CODE=?, PROJECT_NAME=? where PRO_ID=?

Hibernate: update PROJECT_PID_REGION set REG_REGION_CODE=?, PROJECT_NAME=? where PRO_ID=?

18:21:21,796 ERROR org.hibernate.util.JDBCExceptionReporter - ORA-01401: inserted value too large for column



18:21:21,796 ERROR org.hibernate.util.JDBCExceptionReporter - ORA-01401: inserted value too large for column



18:21:21,796 ERROR org.hibernate.event.def.AbstractFlushingEventListener - Could not synchronize database state with session

org.hibernate.exception.GenericJDBCException: could not update: [com.db.hibernate.ProjectRegionInfo#2006]

at org.hibernate.exception.ErrorCodeConverter.handledNonSpecificException(ErrorCodeConverter.java:92)

at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:80)

at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)

at org.hibernate.persister.entity.BasicEntityPersister.update(BasicEntityPersister.java:1990)

at org.hibernate.persister.entity.BasicEntityPersister.updateOrInsert(BasicEntityPersister.java:1899)

at org.hibernate.persister.entity.BasicEntityPersister.update(BasicEntityPersister.java:2139)

at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:75)

at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:239)

at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:223)

at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:137)

at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)

at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)

at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:678)

at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:309)

at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)

at com.db.generic.HibernateFilter.doFilter(HibernateFilter.java:65)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)

at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)

at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)

at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)

at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)

at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)

at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)

at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)

at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)

at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)

at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)

at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)

at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)

at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)

at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)

at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)

at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)

at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)

at java.lang.Thread.run(Thread.java:534)

Caused by: java.sql.BatchUpdateException: ORA-01401: inserted value too large for column



at oracle.jdbc.dbaccess.DBError.throwBatchUpdateException(DBError.java:441)

at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:3377)

at org.apache.commons.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:294)

at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:57)

at org.hibernate.jdbc.BatchingBatcher.addToBatch(BatchingBatcher.java:33)

at org.hibernate.persister.entity.BasicEntityPersister.update(BasicEntityPersister.java:1972)

... 38 more



------------------------------------------------------------------------------------
Please Help me on this soon

_________________
Cnu


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 28, 2007 8:50 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
You have long strings being passed? You should enable the debug entry to see the arguments being passed to the query.

BTW: Where did you get this modified version of Middlgen from? What been done to it?


Top
 Profile  
 
 Post subject: Exception-inserted value is too large for a column(From Cnu)
PostPosted: Tue May 29, 2007 10:20 am 
Newbie

Joined: Mon May 28, 2007 10:53 am
Posts: 4
i am not inserting any values anywhere, when my jsp is loading it is accessing the pojo's.
As per my knowledge it has to load the object i.e select query has to execute but update query is executing may i know what is reason.

i have seen the strings length(which i am featching) ,their sizes in the table and the properties length in .hbm files is same.(Please see my files above)

this exception is not stoping me to navigate to different jsps

Please Help ME Soon.......

in adv Thx.

_________________
Cnu


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.