相关疑难解决方法(0)

JPA,Mysql Blob返回的数据太长

byte[]我的实体中有一些字段,例如:

@Entity
public class ServicePicture implements Serializable {
    private static final long serialVersionUID = 2877629751219730559L;
    // seam-gen attributes (you should probably edit these)
    @Id
    @GeneratedValue
    private Long id;
    private String description;

    @Lob
    @Basic(fetch = FetchType.LAZY)
    private byte[] picture;
Run Code Online (Sandbox Code Playgroud)

在我的数据库架构上,字段设置为,BLOB所以这应该没问题.无论如何:每当我尝试插入图片或pdf时 - 没有什么比1mb这更大,我只接受这个

16:52:27,327 WARN  [JDBCExceptionReporter] SQL Error: 0, SQLState: 22001
16:52:27,327 ERROR [JDBCExceptionReporter] Data truncation: Data too long for column 'picture' at row 1
16:52:27,328 ERROR [STDERR] javax.persistence.PersistenceException: org.hibernate.exception.DataException: could not insert: [de.ac.dmg.productfinder.entity.ServicePicture]
16:52:27,328 ERROR [STDERR] …
Run Code Online (Sandbox Code Playgroud)

java hibernate jpa blob

55
推荐指数
1
解决办法
5万
查看次数

26
推荐指数
2
解决办法
8万
查看次数

带有HSQLDB的Hibernate 4.1提供'数据异常:字符串数据,右截断'

我有一个非常奇怪的问题,当我升级som deps到项目时得到它.

我现在使用以下版本:

  • 春天:3.1.0.RELEASE
  • Hibernate:4.1.7.Final
  • Hsqldb:2.2.8(org.hsqldb)

我认为问题必须与文件字段做一些事情.(Dbfile.content)

堆栈跟踪:

javax.persistence.PersistenceException: org.hibernate.exception.DataException: could not insert: [org.project.model.Cv]
    at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1387)
    at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1315)
    at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1321)
    at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:843)
    at sun.reflect.GeneratedMethodAccessor11.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:240)
    at $Proxy36.persist(Unknown Source)
    at org.project.dao.jpa.GenericDaoJpa.save(GenericDaoJpa.java:49)
    at sun.reflect.GeneratedMethodAccessor10.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
    at $Proxy40.save(Unknown Source)
    at org.project.dao.CvDaoTest.updateTest(CvDaoTest.java:77)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
    at …
Run Code Online (Sandbox Code Playgroud)

spring hibernate jpa hsqldb c3p0

16
推荐指数
4
解决办法
3万
查看次数

不推荐使用的Hibernate.createClob(Reader reader,int length)的替代品是什么

似乎Hibernate.createClob(Reader reader, int length)在版本3.6.x中已弃用.它建议使用Use LobHelper.createClob(Reader, long)代替.

但是LobHelper接口不是一个类.

有替代品 static method Hibernate.createClob(Reader reader, int length)吗?

hibernate clob deprecated

4
推荐指数
1
解决办法
1万
查看次数

标签 统计

hibernate ×3

java ×2

jpa ×2

blob ×1

c3p0 ×1

clob ×1

deprecated ×1

hsqldb ×1

image ×1

jsp ×1

servlets ×1

spring ×1