Showing posts with label hibernate. Show all posts
Showing posts with label hibernate. Show all posts

Sep 18, 2014

org.hsqldb.HsqlException: data exception: string data, right truncation; table

Hi,

I had this exception while testing (junit) my code.

It seems that when you use +Hibernate.org  Lob annotation and use HsqlDB, the default column size is probably less than the actual size you are trying to insert. In my case i annotated String with Lob (hibernate knows it should be clob) while my string length was huge -> got this exception.

To fix this, add hibernate column annotation with column length bigger like 15000 , this will solve it  (for example of course).


Hoped it helped,


Dor

Jun 5, 2014

log4j.properties

Sample log4j property file, logging only to file, if you want console add 'stdout' in the rootlogger and remove the comments in the section below.
I included hibernate and spring logging relevant

# Root logger option
log4j.rootLogger=INFO, file

log4j.category.com=WARN
log4j.category.org=WARN
log4j.category.com.softweave=DEBUG
log4j.category.org.springframework=INFO
#log4j.category.org.springframework.beans.factory=INFO
#log4j.category.org.springframework.beans.factory.support=INFO
log4j.category.org.apache.cxf.service.factory.ReflectionServiceFactoryBean=WARN
log4j.category.org.hibernate.hql.internal.ast.HqlSqlWalker=ERROR
log4j.category.org.hibernate.SQL=INFO

# To see hibernate parameters in the query and not just ? you must set this to TRACE
log4j.category.org.hibernate.type=INFO
log4j.category.org.hibernate.tool.hbm2ddl=INFO

# Direct log messages to a log file
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=log_file_name_and_location.log
log4j.appender.file.MaxFileSize=10MB
log4j.appender.file.MaxBackupIndex=10
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %5p %c{1}:%L - %m%n

# Direct log messages to stdout
#log4j.appender.stdout=org.apache.log4j.ConsoleAppender
#log4j.appender.stdout.Target=System.out
#log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
#log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - #%m%n

# spring transaction log
log4j.logger.org.springframework.orm.jpa=INFO
log4j.logger.org.springframework.transaction=INFO
#log4j.logger.org.springframework.orm.hibernate3.HibernateTransactionManager=DEBUG

# hibernate full details log
log4j.logger.org.hibernate=INFO
#log4j.logger.org.hibernate.type=trace

Jul 9, 2012

Spring Hibernate Envers java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.(I)V

Issue occurred to my college at work. It means that spring uses already the envers as a dependency inside it and you are trying to add it also with a different version. As result -> Conflict.
For me it happened with
spring 3.0.5
hibernate 3.6.0.FINAL
* We added hibernate-envers 3.6.0.FINAL.

Solution
Replacing hibernate-envers with the latest, current latest is 4.1.4 but you should look in maven repository.



Jan 6, 2011

java.lang.ClassNotFoundException: javassist.util.proxy.MethodFilter

I got this error while using maven, jetty, wicket, spring and hibernate all with annotations.
Found two solutions
1) Get the java assist jar using maven, but them i got into some other problems.

2) Use this :

 <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-jaxrs</artifactId>
  </dependency>
It seems that it solved the issue since the jaxrs contains this method filter.

If you know other or better solution, i am here to listen.

Hoped it helped,
Dor

Nov 23, 2010

Fail to convert to internal representation

Hi,
Once it happened to me, you figure out what's wrong, write it down for just in case.
Then it happens to your friend.
It means that one of the types defined in your hibernate hbm file or annotated is wrong.
For example if you need to represent in your hbm file a boolean as the primitive type or it's appropriate wrapper, you may use "yes_no" as the type.
Dor