Annotation @Lob - Trying to save files on Oracle DB [message #909807] |
Fri, 07 September 2012 20:57 |
Lars Drießnack Messages: 9 Registered: August 2012 |
Junior Member |
|
|
Hello,
I'm trying to store/load images on Oracle 10g database with JPA/EclipseLink.
Code:
@Entity
@Table(name = "MYPICTURE")
public class Picture extends BaseObject {
private static final long serialVersionUID = -1094665703939324532L;
public static final int SIZE_1MB = 1000000;
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "PICTURE_SEQ")
@SequenceGenerator(name = "PICTURE_SEQ", sequenceName = "PICTURE_SEQUENCE", initialValue = 1, allocationSize = 1)
@Column
@NotNull
private Long id;
@Lob
@Basic(fetch = FetchType.LAZY)
@Column(name = "content", length = SIZE_1MB)
@NotNull
private byte[] content;
@Column(name = "type")
@Converter(name = "mimeTypeConverter", converterClass = ...MimeTypeConverter.class)
@Convert("mimeTypeConverter")
@NotNull
private MimeType type;
...
getter / setter
I wrote a UnitTest and tried to store a 6kb (very small) image. It should be possible to store a image with a size up to 1MB. The test produces the following exception:
javax.persistence.RollbackException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Datengröße größer als max. Größe für diesen Typ: 5911
Error Code: 17070
Call: INSERT INTO MYPICTURE (ID, content, INSERTEDAT, INSERTEDBY, type, UPDATEDAT, UPDATEDBY) VALUES (?, ?, ?, ?, ?, ?, ?)
bind => [1, [B@75f07729, 2012-09-07T22:49:58.594+02:00, todo, image/png, null, null]
Query: InsertObjectQuery(...picture.Picture@55a86b8d)
The exception is german so it says something like: File size is to large max. size for this type 5911.
I've searched a very long time for a solution. Any suggestions? DB Version is Oracle 10g, EclipseLink 2.3.2 Indigo.
kind regards
Lars
[Updated on: Fri, 07 September 2012 21:02] Report message to a moderator
|
|
|
|
Re: Annotation @Lob - Trying to save files on Oracle DB [message #915372 is a reply to message #911344] |
Mon, 17 September 2012 06:48 |
Lars Drießnack Messages: 9 Registered: August 2012 |
Junior Member |
|
|
Hi,
I changed the eclipselink.target-database property to Oracle10g, now I get the following exception:
[[b]EL Fine]: Connection(42932808)--INSERT INTO PICTURE (ID, content, INSERTEDAT, INSERTEDBY, mimetype, UPDATEDAT, UPDATEDBY) VALUES (?, ?, ?, ?, ?, ?, ?)
bind => [1, [B@3a8c4b43, 2012-09-17T08:38:03.158+02:00, todo, image/png, null, null]
[EL Fine]: Connection(42932808)--SELECT content FROM PICTURE WHERE (ID = ?) FOR UPDATE
bind => [1]
[EL Fine]: SELECT 1 FROM DUAL
[EL Warning]: Local Exception Stack:
Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Nicht unterstützte Funktion
Error Code: 17023
Call: SELECT content FROM PICTURE WHERE (ID = ?) FOR UPDATE
bind => [1][/b]
Query: InsertObjectQuery(...picture.Picture@33a90fd9)
at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:333)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:644)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:535)
at org.eclipse.persistence.internal.helper.LOBValueWriter.buildAndExecuteCall(LOBValueWriter.java:77)
at org.eclipse.persistence.internal.helper.LOBValueWriter.buildAndExecuteSelectCalls(LOBValueWriter.java:188)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.flushSelectCalls(DatabaseAccessor.java:156)
at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.insertObject(DatasourceCallQueryMechanism.java:367)
at org.eclipse.persistence.internal.queries.StatementQueryMechanism.insertObject(StatementQueryMechanism.java:162)
at org.eclipse.persistence.internal.queries.StatementQueryMechanism.insertObject(StatementQueryMechanism.java:177)
at org.eclipse.persistence.internal.queries.DatabaseQueryMechanism.insertObjectForWrite(DatabaseQueryMechanism.java:472)
at org.eclipse.persistence.queries.InsertObjectQuery.executeCommit(InsertObjectQuery.java:80)
at org.eclipse.persistence.queries.InsertObjectQuery.executeCommitWithChangeSet(InsertObjectQuery.java:90)
at org.eclipse.persistence.internal.queries.DatabaseQueryMechanism.executeWriteWithChangeSet(DatabaseQueryMechanism.java:287)
at org.eclipse.persistence.queries.WriteObjectQuery.executeDatabaseQuery(WriteObjectQuery.java:58)
at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:844)
at org.eclipse.persistence.queries.DatabaseQuery.executeInUnitOfWork(DatabaseQuery.java:743)
at org.eclipse.persistence.queries.ObjectLevelModifyQuery.executeInUnitOfWorkObjectLevelModifyQuery(ObjectLevelModifyQuery.java:108)
at org.eclipse.persistence.queries.ObjectLevelModifyQuery.executeInUnitOfWork(ObjectLevelModifyQuery.java:85)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2871)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1516)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1498)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1449)
at org.eclipse.persistence.internal.sessions.CommitManager.commitNewObjectsForClassWithChangeSet(CommitManager.java:224)
at org.eclipse.persistence.internal.sessions.CommitManager.commitAllObjectsWithChangeSet(CommitManager.java:123)
at org.eclipse.persistence.internal.sessions.AbstractSession.writeAllObjectsWithChangeSet(AbstractSession.java:3799)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitToDatabase(UnitOfWorkImpl.java:1415)
at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.commitToDatabase(RepeatableWriteUnitOfWork.java:636)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitToDatabaseWithChangeSet(UnitOfWorkImpl.java:1505)
at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.commitRootUnitOfWork(RepeatableWriteUnitOfWork.java:267)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitAndResume(UnitOfWorkImpl.java:1143)
at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commitInternal(EntityTransactionImpl.java:84)
at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commit(EntityTransactionImpl.java:63)
...
Caused by: java.sql.SQLException: Nicht unterstützte Funktion
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:269)
at [b]oracle.jdbc.dbaccess.DBError.throwUnsupportedFeatureSqlException(DBError.java:689)
at oracle.sql.BLOB.setBytes(BLOB.java:954)
at org.eclipse.persistence.platform.database.oracle.Oracle10Platform.writeLOB(Oracle10Platform.java:72)
at org.eclipse.persistence.internal.helper.LOBValueWriter.fetchLocatorAndWriteValue(LOBValueWriter.java:92)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.processResultSet(DatabaseAccessor.java:695)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:621)[/b]
... 56 more
kind regards,
Lars
[Updated on: Mon, 17 September 2012 06:49] Report message to a moderator
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04251 seconds