-->
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: Long strings and Ingres
PostPosted: Thu Jun 09, 2005 5:38 am 
Newbie

Joined: Tue May 24, 2005 6:51 am
Posts: 5
Hi there,

I have a table on Ingress that has a column of type varchar(30000) and I'm trying to put a java String in there. I get an error stating that I cannot insert a value of type "long varchar" into a column of type "varchar".

Any suggestions on how to get arround this problem? I've tried <column .... sql-type="long varchar" but it does not do anything.

Thanks for the help.
Stefan



Hibernate version: 3.0.5

Mapping documents:
<?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="za.co.telkom.ubr.model.CodeTemplate"
table="ReplTemplates"
>

<id
name="id"
column="TemplateId"
type="int"
unsaved-value="-1"
>
<generator class="native">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-CodeTemplate.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>

<version
name="version"
column="version"
type="java.lang.Integer"
/>

<property
name="name"
type="java.lang.String"
update="true"
insert="true"
column="TemplateName"
length="64"
not-null="true"
/>

<property
name="type"
type="java.lang.String"
update="true"
insert="true"
column="TemplateType"
length="64"
not-null="true"
/>

<many-to-one
name="dbms"
class="za.co.telkom.ubr.model.Dbms"
cascade="none"
outer-join="auto"
update="true"
insert="true"
column="DBMSId"
not-null="true"
/>

<property
name="fileContent"
type="java.lang.String"
update="true"
insert="true"
>
<column
name="TemplateText"
sql-type="long varchar"
/>
</property>

<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-CodeTemplate.xml
containing the additional properties and place it in your merge dir.
-->

</class>

</hibernate-mapping>

Model class:
/**
* CodeTemplate Class
*
* Represents a Velocity template storage record
*
* @author sbmahs
*
* @hibernate.class table="ReplTemplates"
*/
public class CodeTemplate extends AbstractModelObject implements Serializable {

protected Integer id;

protected Dbms dbms = new Dbms();

protected String name;

protected String type;

protected Integer version;

private byte[] file;

protected String fileContent;


/* (non-Javadoc)
* @see za.co.telkom.ubr.model.AbstractModelObject#isNew()
*/
public boolean isNew() {
return (id == null);
}

/**
* @return the id of this object
*
* @hibernate.id generator-class="native" column="TemplateId"
* unsaved-value="-1"
*/
public int getId() {
return (id == null ? -1 : id.intValue());
}

/**
* @param id The id of this object
*/
public void setId(int id) {
this.id = new Integer(id);
}

/**
* @return The name identifying this template
*
* @hibernate.property column="TemplateName" length="64" not-null="true"
*/
public String getName() {
return name;
}

/**
* @param name
* @spring.validator type="required"
*/
public void setName(String name) {
this.name = name;
}

/**
* @return The template type of this object
*
* @hibernate.property column="TemplateType" length="64" not-null="true"
*/
public String getType() {
return type;
}

/**
* @param type The template type of this object
*/
public void setType(String type) {
this.type = type;
}

/**
* Return the DBMS for this database.
*
* @return Returns the dbms
*
* @hibernate.many-to-one class =
* "za.co.telkom.ubr.model.Dbms"
* column="DBMSId" update="true" insert="true" not-null="true"
* cascade="none" lazy="true"
*/
public Dbms getDbms() {
return this.dbms;
}

/**
* Set a new Dbms object for this database
*
* @param dbms
* The dbms to set.
*/
public void setDbms(Dbms dbms) {
this.dbms = dbms;
}

/**
* @return Returns the file as a byte[]
*/
public byte[] getFile() {
return file;
}

/**
* @param file The file byte[] to set.
* @spring.validator type="required"
*/
public void setFile(byte[] file) {
this.file = file;
}

/**
* @return Returns the file content as a String
*
* @hibernate.property column="TemplateText" length="30000" not-null="true"
* @hibernate.column name="TemplateText" sql-type="long varchar"
*/
public String getFileContent() {
return fileContent;
}

/**
* @param file The file content as a String
* @spring.validator type="required"
*/
public void setFileContent(String fileContent) {
this.fileContent = fileContent;
}

/**
* Return the latest version of this instance of the CodeTemplate.
*
* @return Returns the version.
*
* @hibernate.version
*/
public Integer getVersion() {
return version;
}

/**
* Assign a new version to this instance of the CodeTemplate.
*
* @param version
* The version to set.
*/
public void setVersion(Integer version) {
this.version = version;
}
}

Name and version of the database you are using: Ingres 2.6

The generated SQL (show_sql=true):
[replconsole] 2005-06-09 11:19:58,739 DEBUG [za.co.telkom.ubr.controller.TemplateUploadController] - <Template Upload: got a file of length [21948] bytes>
Hibernate: insert into ReplTemplates (version, TemplateName, TemplateType, DBMSId, TemplateText, TemplateId) values (?, ?, ?, ?, ?, ?)

Debug level Hibernate log excerpt:
[replconsole] 2005-06-09 11:19:58,854 WARN [org.hibernate.util.JDBCExceptionReporter] - <SQL Error: 2913, SQLState: 42000>
[replconsole] 2005-06-09 11:19:58,855 ERROR [org.hibernate.util.JDBCExceptionReporter] - <line 1, You cannot assign a value of type 'long varchar' to a column of type 'varchar'. Explicitly convert the value to the required type.>
[replconsole] 2005-06-09 11:19:58,857 ERROR [org.hibernate.event.def.AbstractFlushingEventListener] - <Could not synchronize database state with session>
org.hibernate.exception.SQLGrammarException: could not insert: [za.co.telkom.ubr.model.CodeTemplate]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:59)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.persister.entity.BasicEntityPersister.insert(BasicEntityPersister.java:1869)
at org.hibernate.persister.entity.BasicEntityPersister.insert(BasicEntityPersister.java:2200)
at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:46)
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:136)
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:730)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:324)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)
at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:470)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:401)
at org.springframework.transaction.interceptor.TransactionAspectSupport.doCommitTransactionAfterReturning(TransactionAspectSupport.java:256)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:67)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:174)
at $Proxy2.storeCodeTemplate(Unknown Source)
at za.co.telkom.ubr.controller.TemplateUploadController.onSubmit(TemplateUploadController.java:179)
at org.springframework.web.servlet.mvc.SimpleFormController.processFormSubmission(SimpleFormController.java:248)
at za.co.telkom.ubr.controller.ApplicationFormController.processFormSubmission(ApplicationFormController.java:114)
at org.springframework.web.servlet.mvc.AbstractFormController.handleRequestInternal(AbstractFormController.java:243)
at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:128)
at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:44)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:675)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:623)
at org.springframework.web.servlet.FrameworkServlet.serviceWrapper(FrameworkServlet.java:384)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:353)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at com.opensymphony.module.sitemesh.filter.PageFilter.parsePage(PageFilter.java:118)
at com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:172)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:75)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at net.sf.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:300)
at net.sf.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:84)
at net.sf.acegisecurity.intercept.web.SecurityEnforcementFilter.doFilter(SecurityEnforcementFilter.java:182)
at net.sf.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:311)
at net.sf.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:153)
at net.sf.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:311)
at net.sf.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:374)
at net.sf.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:311)
at net.sf.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:225)
at net.sf.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:311)
at net.sf.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:179)
at net.sf.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:125)
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.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:738)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
Caused by: ca.edbc.util.EdbcEx: line 1, You cannot assign a value of type 'long varchar' to a column of type 'varchar'. Explicitly convert the value to the required type.
at ca.edbc.jdbc.EdbcObj.readResults(EdbcObj.java:782)
at ca.edbc.jdbc.EdbcObj.readResults(EdbcObj.java:573)
at ca.edbc.jdbc.EdbcPrep.exec(EdbcPrep.java:771)
at ca.edbc.jdbc.EdbcPrep.executeUpdate(EdbcPrep.java:442)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:101)
at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:22)
at org.hibernate.persister.entity.BasicEntityPersister.insert(BasicEntityPersister.java:1853)
... 69 more


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 14, 2006 1:04 pm 
Newbie

Joined: Tue Oct 11, 2005 10:57 am
Posts: 13
Hi, Stefan.

I had the same problem, but with 'text' instead 'varchar'.

I converted the field 'text' of the table to 'long varchar'. This was the only solution that I had found.

Reinaldo.


Top
 Profile  
 
 Post subject: Re: Long strings and Ingres
PostPosted: Mon Apr 23, 2012 7:48 am 
Newbie

Joined: Mon Apr 23, 2012 7:40 am
Posts: 1
Your post about Hibernates various version also model related well post. I think it is really useful to me. Also I want to know about Telkom. Please tell me about Telkom because I want to get connection with Telkom.


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.