I am with problem in save images... I saw other solution using bytea, but I don't know how use annotations with it.
Hibernate version:
3.0
Mapping documents:
@NotNull(message = FramexMessages.FRAMEX_REQUIRED_FIELD)
@Lob @Basic(fetch = FetchType.EAGER)
public byte[] getArquivoImagem() {
return arquivoImagem;
}
Full stack trace of any exception that occurs:
org.hibernate.exception.GenericJDBCException: could not insert: [br.com.atlantico.maragato.cadastrosauxiliares.model.ImagemTO]
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:91)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:79)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2078)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2427)
at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:51)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:243)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:227)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:296)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1009)
at br.com.atlantico.framexunit.test.AbstractMaragatoCRUDBOTestCase.commitTransactionAndCloseSession(AbstractMaragatoCRUDBOTestCase.java:313)
at br.com.atlantico.framexunit.test.AbstractMaragatoCRUDBOTestCase.afterOperation(AbstractMaragatoCRUDBOTestCase.java:360)
at br.com.atlantico.maragato.cadastrosauxiliares.businessobject.ImagemBOTest.testCreateHappyDay(ImagemBOTest.java:61)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: org.postgresql.util.PSQLException: Objetos Grandes não podem ser usados no modo de efetivação automática (auto-commit).
at org.postgresql.largeobject.LargeObjectManager.create(LargeObjectManager.java:200)
at org.postgresql.largeobject.LargeObjectManager.create(LargeObjectManager.java:187)
at org.postgresql.jdbc2.AbstractJdbc2Statement.setBlob(AbstractJdbc2Statement.java:2683)
at org.apache.commons.dbcp.DelegatingPreparedStatement.setBlob(DelegatingPreparedStatement.java:180)
at org.hibernate.type.ByteArrayBlobType.set(ByteArrayBlobType.java:103)
at org.hibernate.type.AbstractLobType.nullSafeSet(AbstractLobType.java:54)
at org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:1826)
at org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:1803)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2059)
... 26 more
Name and version of the database you are using:
Postgres SQL
The generated SQL (show_sql=true):
CREATE TABLE imagem
(
id int8 NOT NULL,
arquivo_imagem oid NOT NULL,
tipo int4 NOT NULL,
titulo varchar(100) NOT NULL,
CONSTRAINT imagem_pkey PRIMARY KEY (id),
CONSTRAINT imagem_titulo_key UNIQUE (titulo)
)
WITHOUT OIDS;
ALTER TABLE imagem OWNER TO postgres;
|