You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by hantone <ho...@gmail.com> on 2009/01/27 18:16:15 UTC

Nested Exception Error

Thanks in advance! I'm having a hard time with this so I would really
appreciate your help!

I'm having problems to commit a transaction

public class Main {
	public static void main(String[] args) {
		try {
			EntityManager entityManager = 
Persistence.createEntityManagerFactory("ReportAndPay").createEntityManager();;
			EntityTransaction transaction = entityManager.getTransaction();
			transaction.begin();
			Reports report = entityManager.find(Reports.class, new Inhteger(2001));
			Blob file = null;
			try {
				file = new SerialBlob("PEPE".getBytes());
			} catch (SQLException e) {}
			report.getOutboundFileses().add(new OutboundFiles(report, file ,
"Type","Status"));
			entityManager.merge(report);
			transaction.commit();
			entityManager.close();
		} catch(RuntimeException rte) {
			System.out.println(rte.getStackTrace());
		}
	}
}

When I debug it, an exception happened when executing
"transaction.commit();", I get this error message 
"The transaction has been rolled back.  See the nested exceptions for
details on the errors that occurred.", the error cause is
<openjpa-1.2.0-r422266:683325 fatal store error>
org.apache.openjpa.persistence.RollbackException: The transaction has been
rolled back.  See the nested exceptions for details on the errors that
occurred.



@Entity
@Table(name = "REPORTS", schema = "MYPROY")
@SequenceGenerator(name="ReportsSeq",
sequenceName="MYPRO.REPORT_ROW_ID_SEQ1", initialValue=1, allocationSize=1)
public class Reports implements java.io.Serializable {
	private int reportRowId;
	private String status;
	private Date created;
	private Set<OutboundFiles> outboundFileses = new HashSet<OutboundFiles>(0);
        ...

	@Id
	@Column(name = "REPORT_ROW_ID", unique = true, nullable = false)
	@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="ReportsSeq")
	public int getReportRowId() {
		return this.reportRowId;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy =
"reports")
	public Set<OutboundFiles> getOutboundFileses() {
		return this.outboundFileses;
	}
}




@Entity
@Table(name = "OUTBOUND_FILES", schema = "MYPROY")
@SequenceGenerator(name="OutboundFilesSeq",
sequenceName="WWBPSM.OUTBOUND_FILE_ROW_ID_SEQ1", initialValue=1,
allocationSize=1)
public class OutboundFiles implements java.io.Serializable {
	private int outboundFileRowId;
	private Reports reports;
	private Blob file;
	private String fileType;
	private String status;

	public OutboundFiles() {
	}

	public OutboundFiles(int outboundFileRowId, Reports reports, Blob file,
			String fileType) {
		this.outboundFileRowId = outboundFileRowId;
		this.reports = reports;
		this.file = file;
		this.fileType = fileType;
	}
	public OutboundFiles(Reports reports, Blob file,String fileType, String
status) {
		this.reports = reports;
		this.file = file;
		this.fileType = fileType;
		this.status = status;
	}
	@Id
	@Column(name = "OUTBOUND_FILE_ROW_ID", unique = true, nullable = false)
	@GeneratedValue(strategy=GenerationType.SEQUENCE,
generator="OutboundFilesSeq")
	public int getOutboundFileRowId() {
		return this.outboundFileRowId;
	}
}

the same error happens as well if I use

public class Main {
	public static void main(String[] args) {
		try {
			EntityManager entityManager = 
Persistence.createEntityManagerFactory("ReportAndPay").createEntityManager();;
			EntityTransaction transaction = entityManager.getTransaction();
			transaction.begin();
			Reports report = entityManager.find(Reports.class, new Integer(2001));
			Blob file = null;
			try {
				file = new SerialBlob("PEPE".getBytes());
			} catch (SQLException e) {}
			OutboundFiles outboundFiles = new OutboundFiles(report, file ,
"Type","Status");
			entityManager.persist(outboundFiles);
			transaction.commit();
			entityManager.close();
		} catch(RuntimeException rte) {
			System.out.println(rte.getMessage());
		}
	}
}


-- 
View this message in context: http://n2.nabble.com/Nested-Exception-Error-tp2226964p2226964.html
Sent from the OpenJPA Developers mailing list archive at Nabble.com.


Re: Nested Exception Error

Posted by hantone <ho...@gmail.com>.
Hi Mike! Thanks for the quick andwer, at the botton is part of the log file

The problem seems to be that it try to execute this query

INSERT INTO WWBPSM.OUTBOUND_FILES (OUTBOUND_FILE_ROW_ID, FILE_TYPE, 
        STATUS, REPORT_ROW_ID) 
    VALUES (?, ?, ?, ?) 

and not :

INSERT INTO WWBPSM.OUTBOUND_FILES (OUTBOUND_FILE_ROW_ID, FILE_TYPE, 
        STATUS, REPORT_ROW_ID, FILE) 
    VALUES (?, ?, ?, ?, ?) 

the query being  executed is not inserting the file field that is a Blob ,
it is required not to be null, that's why it is logging "Assignment of a
NULL value to a NOT NULL column"

public class OutboundFiles implements java.io.Serializable {
        private int outboundFileRowId;
	private Reports reports;
	private Blob file;
	private String fileType;
	private String status;

        public OutboundFiles(Reports reports, Blob file,  
			String fileType, String status) {
		this.reports = reports;
		this.file = file;
		this.fileType = fileType;
		this.status = status;
	}

        @Column(name = "FILE", nullable = false)
	public Blob getFile() {
		return this.file;
	}
}

that I set the blog in the Main with

	Blob file = null;
	try {
		file = new SerialBlob("PEPE".getBytes());
	} catch (SQLException e) {}
	OutboundFiles outboundFiles = new OutboundFiles(report, file,
"Type","Status");

It seems that the problem could be in the mapping, as it seems that is not
creating a mapping for the "file field", as you can see in the log below


Do you know how to fix this?

Thank in advance!

- Horacio



PART OF THE LOG FILE

33171  ReportAndPay  TRACE  [main] openjpa.MetaData - Resolving mapping for
"com.ibm.gatewayservices.model.OutboundFiles@712125042".
33171  ReportAndPay  TRACE  [main] openjpa.MetaData -
"com.ibm.gatewayservices.model.OutboundFiles" has mapping strategy "full".
33171  ReportAndPay  TRACE  [main] openjpa.MetaData - Initializing mapping
for "com.ibm.gatewayservices.model.OutboundFiles@712125042".
33171  ReportAndPay  TRACE  [main] openjpa.MetaData - 	Resolving field
"com.ibm.gatewayservices.model.OutboundFiles@712125042.fileType".
33171  ReportAndPay  TRACE  [main] openjpa.MetaData - 	Resolving field
"com.ibm.gatewayservices.model.OutboundFiles@712125042.outboundFileRowId".
33171  ReportAndPay  TRACE  [main] openjpa.MetaData - 	Resolving field
"com.ibm.gatewayservices.model.OutboundFiles@712125042.reports".
33171  ReportAndPay  TRACE  [main] openjpa.MetaData - 	Resolving field
"com.ibm.gatewayservices.model.OutboundFiles@712125042.status".

49609  ReportAndPay  TRACE  [main] openjpa.jdbc.SQL - <t 1090273532, conn
232787424> executing prepstmnt 1157514494 
INSERT INTO WWBPSM.OUTBOUND_FILES (OUTBOUND_FILE_ROW_ID, FILE_TYPE, 
        STATUS, REPORT_ROW_ID) 
    VALUES (?, ?, ?, ?) 
[params=(int) 843, (String) Type, (String) Status, (int) 2001]
49625  ReportAndPay  TRACE  [main] openjpa.jdbc.SQL - <t 1090273532, conn
232787424> [16 ms] spent
49640  ReportAndPay  TRACE  [main] openjpa.Runtime - An exception occurred
while ending the transaction.  This exception will be re-thrown.
<openjpa-1.2.0-r422266:683325 fatal store error>
org.apache.openjpa.util.StoreException: The transaction has been rolled
back.  See the nested exceptions for details on the errors that occurred.
	at
org.apache.openjpa.kernel.BrokerImpl.newFlushException(BrokerImpl.java:2163)
	at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:2010)
	at org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:1908)
	at
org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(BrokerImpl.java:1826)
	at
org.apache.openjpa.kernel.LocalManagedRuntime.commit(LocalManagedRuntime.java:81)
	at org.apache.openjpa.kernel.BrokerImpl.commit(BrokerImpl.java:1350)
	at
org.apache.openjpa.kernel.DelegatingBroker.commit(DelegatingBroker.java:877)
	at
org.apache.openjpa.persistence.EntityManagerImpl.commit(EntityManagerImpl.java:512)
	at com.ibm.gatewayservices.test.Main.main(Main.java:45)
Caused by: <openjpa-1.2.0-r422266:683325 nonfatal store error>
org.apache.openjpa.util.StoreException: [IBM][CLI Driver][DB2/NT] SQL0407N 
Assignment of a NULL value to a NOT NULL column "TBSPACEID=2, TABLEID=263,
COLNO=2" is not allowed.  SQLSTATE=23502

FailedObject: prepstmnt 1157514494 
INSERT INTO WWBPSM.OUTBOUND_FILES (OUTBOUND_FILE_ROW_ID, FILE_TYPE, 
        STATUS, REPORT_ROW_ID) 
    VALUES (?, ?, ?, ?) 
 [org.apache.openjpa.jdbc.kernel.JDBCStoreManager$CancelPreparedStatement]
	at org.apache.openjpa.jdbc.sql.DBDictionary.narrow(DBDictionary.java:4238)
	at
org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictionary.java:4203)
	at
org.apache.openjpa.jdbc.sql.DB2Dictionary.newStoreException(DB2Dictionary.java:503)
	at
org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:102)
	at
org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:72)
	at
org.apache.openjpa.jdbc.kernel.BatchingPreparedStatementManagerImpl.flushBatch(BatchingPreparedStatementManagerImpl.java:195)
	at
org.apache.openjpa.jdbc.kernel.BatchingConstraintUpdateManager.flush(BatchingConstraintUpdateManager.java:63)
	at
org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:89)
	at
org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:72)
	at
org.apache.openjpa.jdbc.kernel.JDBCStoreManager.flush(JDBCStoreManager.java:655)
	at
org.apache.openjpa.kernel.DelegatingStoreManager.flush(DelegatingStoreManager.java:130)
	... 8 more
Caused by: COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2/NT] SQL0407N 
Assignment of a NULL value to a NOT NULL column "TBSPACEID=2, TABLEID=263,
COLNO=2" is not allowed.  SQLSTATE=23502

	at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLException(Unknown
Source)
	at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLException(Unknown
Source)
	at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.check_return_code(Unknown
Source)
	at COM.ibm.db2.jdbc.app.DB2PreparedStatement.execute2(Unknown Source)
	at COM.ibm.db2.jdbc.app.DB2PreparedStatement.executeUpdate(Unknown Source)
	at
org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:102)
	at
org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:269)
	at
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingPreparedStatement.executeUpdate(LoggingConnectionDecorator.java:864)
	at
org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:269)
	at
org.apache.openjpa.jdbc.kernel.JDBCStoreManager$CancelPreparedStatement.executeUpdate(JDBCStoreManager.java:1504)
	at
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.executeUpdate(PreparedStatementManagerImpl.java:151)
	at
org.apache.openjpa.jdbc.kernel.BatchingPreparedStatementManagerImpl.flushSingleRow(BatchingPreparedStatementManagerImpl.java:217)
	at
org.apache.openjpa.jdbc.kernel.BatchingPreparedStatementManagerImpl.flushBatch(BatchingPreparedStatementManagerImpl.java:156)
	... 13 more
49640  ReportAndPay  TRACE  [main] openjpa.jdbc.JDBC - <t 1090273532, conn
232787424> [0 ms] rollback
49640  ReportAndPay  TRACE  [main] openjpa.jdbc.JDBC - <t 1090273532, conn
0> [0 ms] close
49671  ReportAndPay  TRACE  [main] openjpa.Runtime - An exception occurred
while ending the transaction.  This exception will be re-thrown.
<openjpa-1.2.0-r422266:683325 fatal store error>
org.apache.openjpa.util.StoreException: The transaction has been rolled
back.  See the nested exceptions for details on the errors that occurred.
	at
org.apache.openjpa.kernel.BrokerImpl.newFlushException(BrokerImpl.java:2163)
	at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:2010)
	at org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:1908)
	at
org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(BrokerImpl.java:1826)
	at
org.apache.openjpa.kernel.LocalManagedRuntime.commit(LocalManagedRuntime.java:81)
	at org.apache.openjpa.kernel.BrokerImpl.commit(BrokerImpl.java:1350)
	at
org.apache.openjpa.kernel.DelegatingBroker.commit(DelegatingBroker.java:877)
	at
org.apache.openjpa.persistence.EntityManagerImpl.commit(EntityManagerImpl.java:512)
	at com.ibm.gatewayservices.test.Main.main(Main.java:45)
Caused by: <openjpa-1.2.0-r422266:683325 nonfatal store error>
org.apache.openjpa.util.StoreException: [IBM][CLI Driver][DB2/NT] SQL0407N 
Assignment of a NULL value to a NOT NULL column "TBSPACEID=2, TABLEID=263,
COLNO=2" is not allowed.  SQLSTATE=23502

FailedObject: prepstmnt 1157514494 
INSERT INTO WWBPSM.OUTBOUND_FILES (OUTBOUND_FILE_ROW_ID, FILE_TYPE, 
        STATUS, REPORT_ROW_ID) 
    VALUES (?, ?, ?, ?) 
 [org.apache.openjpa.jdbc.kernel.JDBCStoreManager$CancelPreparedStatement]
	at org.apache.openjpa.jdbc.sql.DBDictionary.narrow(DBDictionary.java:4238)
	at
org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictionary.java:4203)
	at
org.apache.openjpa.jdbc.sql.DB2Dictionary.newStoreException(DB2Dictionary.java:503)
	at
org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:102)
	at
org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:72)
	at
org.apache.openjpa.jdbc.kernel.BatchingPreparedStatementManagerImpl.flushBatch(BatchingPreparedStatementManagerImpl.java:195)
	at
org.apache.openjpa.jdbc.kernel.BatchingConstraintUpdateManager.flush(BatchingConstraintUpdateManager.java:63)
	at
org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:89)
	at
org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java:72)
	at
org.apache.openjpa.jdbc.kernel.JDBCStoreManager.flush(JDBCStoreManager.java:655)
	at
org.apache.openjpa.kernel.DelegatingStoreManager.flush(DelegatingStoreManager.java:130)
	... 8 more
Caused by: COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2/NT] SQL0407N 
Assignment of a NULL value to a NOT NULL column "TBSPACEID=2, TABLEID=263,
COLNO=2" is not allowed.  SQLSTATE=23502

	at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLException(Unknown
Source)
	at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLException(Unknown
Source)
	at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.check_return_code(Unknown
Source)
	at COM.ibm.db2.jdbc.app.DB2PreparedStatement.execute2(Unknown Source)
	at COM.ibm.db2.jdbc.app.DB2PreparedStatement.executeUpdate(Unknown Source)
	at
org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:102)
	at
org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:269)
	at
org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingPreparedStatement.executeUpdate(LoggingConnectionDecorator.java:864)
	at
org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:269)
	at
org.apache.openjpa.jdbc.kernel.JDBCStoreManager$CancelPreparedStatement.executeUpdate(JDBCStoreManager.java:1504)
	at
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.executeUpdate(PreparedStatementManagerImpl.java:151)
	at
org.apache.openjpa.jdbc.kernel.BatchingPreparedStatementManagerImpl.flushSingleRow(BatchingPreparedStatementManagerImpl.java:217)
	at
org.apache.openjpa.jdbc.kernel.BatchingPreparedStatementManagerImpl.flushBatch(BatchingPreparedStatementManagerImpl.java:156)
	... 13 more

Michael Dick wrote:
> 
> Hi Hantone,
> 
> Could you post the nested exception from inside the RollbackException?
> There
> should be a SQLException as the innermost nested exception that will shed
> some light on the problem.
> 
> Thanks,
> 
> -mike
> 
> On Tue, Jan 27, 2009 at 11:16 AM, hantone
> <ho...@gmail.com>wrote:
> 
>>
>> Thanks in advance! I'm having a hard time with this so I would really
>> appreciate your help!
>>
>> I'm having problems to commit a transaction
>>
>> public class Main {
>>        public static void main(String[] args) {
>>                try {
>>                        EntityManager entityManager =
>>
>> Persistence.createEntityManagerFactory("ReportAndPay").createEntityManager();;
>>                        EntityTransaction transaction =
>> entityManager.getTransaction();
>>                        transaction.begin();
>>                        Reports report = entityManager.find(Reports.class,
>> new Inhteger(2001));
>>                        Blob file = null;
>>                        try {
>>                                file = new SerialBlob("PEPE".getBytes());
>>                        } catch (SQLException e) {}
>>                        report.getOutboundFileses().add(new
>> OutboundFiles(report, file ,
>> "Type","Status"));
>>                        entityManager.merge(report);
>>                        transaction.commit();
>>                        entityManager.close();
>>                } catch(RuntimeException rte) {
>>                        System.out.println(rte.getStackTrace());
>>                }
>>        }
>> }
>>
>> When I debug it, an exception happened when executing
>> "transaction.commit();", I get this error message
>> "The transaction has been rolled back.  See the nested exceptions for
>> details on the errors that occurred.", the error cause is
>> <openjpa-1.2.0-r422266:683325 fatal store error>
>> org.apache.openjpa.persistence.RollbackException: The transaction has
>> been
>> rolled back.  See the nested exceptions for details on the errors that
>> occurred.
>>
>>
>>
>> @Entity
>> @Table(name = "REPORTS", schema = "MYPROY")
>> @SequenceGenerator(name="ReportsSeq",
>> sequenceName="MYPRO.REPORT_ROW_ID_SEQ1", initialValue=1,
>> allocationSize=1)
>> public class Reports implements java.io.Serializable {
>>        private int reportRowId;
>>        private String status;
>>        private Date created;
>>        private Set<OutboundFiles> outboundFileses = new
>> HashSet<OutboundFiles>(0);
>>        ...
>>
>>        @Id
>>        @Column(name = "REPORT_ROW_ID", unique = true, nullable = false)
>>        @GeneratedValue(strategy=GenerationType.SEQUENCE,
>> generator="ReportsSeq")
>>        public int getReportRowId() {
>>                return this.reportRowId;
>>        }
>>
>>        @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY,
>> mappedBy =
>> "reports")
>>        public Set<OutboundFiles> getOutboundFileses() {
>>                return this.outboundFileses;
>>        }
>> }
>>
>>
>>
>>
>> @Entity
>> @Table(name = "OUTBOUND_FILES", schema = "MYPROY")
>> @SequenceGenerator(name="OutboundFilesSeq",
>> sequenceName="WWBPSM.OUTBOUND_FILE_ROW_ID_SEQ1", initialValue=1,
>> allocationSize=1)
>> public class OutboundFiles implements java.io.Serializable {
>>        private int outboundFileRowId;
>>        private Reports reports;
>>        private Blob file;
>>        private String fileType;
>>        private String status;
>>
>>        public OutboundFiles() {
>>        }
>>
>>        public OutboundFiles(int outboundFileRowId, Reports reports, Blob
>> file,
>>                        String fileType) {
>>                this.outboundFileRowId = outboundFileRowId;
>>                this.reports = reports;
>>                this.file = file;
>>                this.fileType = fileType;
>>        }
>>        public OutboundFiles(Reports reports, Blob file,String fileType,
>> String
>> status) {
>>                this.reports = reports;
>>                this.file = file;
>>                this.fileType = fileType;
>>                this.status = status;
>>        }
>>        @Id
>>        @Column(name = "OUTBOUND_FILE_ROW_ID", unique = true, nullable =
>> false)
>>        @GeneratedValue(strategy=GenerationType.SEQUENCE,
>> generator="OutboundFilesSeq")
>>        public int getOutboundFileRowId() {
>>                return this.outboundFileRowId;
>>        }
>> }
>>
>> the same error happens as well if I use
>>
>> public class Main {
>>        public static void main(String[] args) {
>>                try {
>>                        EntityManager entityManager =
>>
>> Persistence.createEntityManagerFactory("ReportAndPay").createEntityManager();;
>>                        EntityTransaction transaction =
>> entityManager.getTransaction();
>>                        transaction.begin();
>>                        Reports report = entityManager.find(Reports.class,
>> new Integer(2001));
>>                        Blob file = null;
>>                        try {
>>                                file = new SerialBlob("PEPE".getBytes());
>>                        } catch (SQLException e) {}
>>                        OutboundFiles outboundFiles = new
>> OutboundFiles(report, file ,
>> "Type","Status");
>>                        entityManager.persist(outboundFiles);
>>                        transaction.commit();
>>                        entityManager.close();
>>                } catch(RuntimeException rte) {
>>                        System.out.println(rte.getMessage());
>>                }
>>        }
>> }
>>
>>
>> --
>> View this message in context:
>> http://n2.nabble.com/Nested-Exception-Error-tp2226964p2226964.html
>> Sent from the OpenJPA Developers mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://n2.nabble.com/Nested-Exception-Error-tp2226964p2231985.html
Sent from the OpenJPA Developers mailing list archive at Nabble.com.


Re: Nested Exception Error

Posted by Michael Dick <mi...@gmail.com>.
Hi Hantone,

Could you post the nested exception from inside the RollbackException? There
should be a SQLException as the innermost nested exception that will shed
some light on the problem.

Thanks,

-mike

On Tue, Jan 27, 2009 at 11:16 AM, hantone <ho...@gmail.com>wrote:

>
> Thanks in advance! I'm having a hard time with this so I would really
> appreciate your help!
>
> I'm having problems to commit a transaction
>
> public class Main {
>        public static void main(String[] args) {
>                try {
>                        EntityManager entityManager =
>
> Persistence.createEntityManagerFactory("ReportAndPay").createEntityManager();;
>                        EntityTransaction transaction =
> entityManager.getTransaction();
>                        transaction.begin();
>                        Reports report = entityManager.find(Reports.class,
> new Inhteger(2001));
>                        Blob file = null;
>                        try {
>                                file = new SerialBlob("PEPE".getBytes());
>                        } catch (SQLException e) {}
>                        report.getOutboundFileses().add(new
> OutboundFiles(report, file ,
> "Type","Status"));
>                        entityManager.merge(report);
>                        transaction.commit();
>                        entityManager.close();
>                } catch(RuntimeException rte) {
>                        System.out.println(rte.getStackTrace());
>                }
>        }
> }
>
> When I debug it, an exception happened when executing
> "transaction.commit();", I get this error message
> "The transaction has been rolled back.  See the nested exceptions for
> details on the errors that occurred.", the error cause is
> <openjpa-1.2.0-r422266:683325 fatal store error>
> org.apache.openjpa.persistence.RollbackException: The transaction has been
> rolled back.  See the nested exceptions for details on the errors that
> occurred.
>
>
>
> @Entity
> @Table(name = "REPORTS", schema = "MYPROY")
> @SequenceGenerator(name="ReportsSeq",
> sequenceName="MYPRO.REPORT_ROW_ID_SEQ1", initialValue=1, allocationSize=1)
> public class Reports implements java.io.Serializable {
>        private int reportRowId;
>        private String status;
>        private Date created;
>        private Set<OutboundFiles> outboundFileses = new
> HashSet<OutboundFiles>(0);
>        ...
>
>        @Id
>        @Column(name = "REPORT_ROW_ID", unique = true, nullable = false)
>        @GeneratedValue(strategy=GenerationType.SEQUENCE,
> generator="ReportsSeq")
>        public int getReportRowId() {
>                return this.reportRowId;
>        }
>
>        @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY,
> mappedBy =
> "reports")
>        public Set<OutboundFiles> getOutboundFileses() {
>                return this.outboundFileses;
>        }
> }
>
>
>
>
> @Entity
> @Table(name = "OUTBOUND_FILES", schema = "MYPROY")
> @SequenceGenerator(name="OutboundFilesSeq",
> sequenceName="WWBPSM.OUTBOUND_FILE_ROW_ID_SEQ1", initialValue=1,
> allocationSize=1)
> public class OutboundFiles implements java.io.Serializable {
>        private int outboundFileRowId;
>        private Reports reports;
>        private Blob file;
>        private String fileType;
>        private String status;
>
>        public OutboundFiles() {
>        }
>
>        public OutboundFiles(int outboundFileRowId, Reports reports, Blob
> file,
>                        String fileType) {
>                this.outboundFileRowId = outboundFileRowId;
>                this.reports = reports;
>                this.file = file;
>                this.fileType = fileType;
>        }
>        public OutboundFiles(Reports reports, Blob file,String fileType,
> String
> status) {
>                this.reports = reports;
>                this.file = file;
>                this.fileType = fileType;
>                this.status = status;
>        }
>        @Id
>        @Column(name = "OUTBOUND_FILE_ROW_ID", unique = true, nullable =
> false)
>        @GeneratedValue(strategy=GenerationType.SEQUENCE,
> generator="OutboundFilesSeq")
>        public int getOutboundFileRowId() {
>                return this.outboundFileRowId;
>        }
> }
>
> the same error happens as well if I use
>
> public class Main {
>        public static void main(String[] args) {
>                try {
>                        EntityManager entityManager =
>
> Persistence.createEntityManagerFactory("ReportAndPay").createEntityManager();;
>                        EntityTransaction transaction =
> entityManager.getTransaction();
>                        transaction.begin();
>                        Reports report = entityManager.find(Reports.class,
> new Integer(2001));
>                        Blob file = null;
>                        try {
>                                file = new SerialBlob("PEPE".getBytes());
>                        } catch (SQLException e) {}
>                        OutboundFiles outboundFiles = new
> OutboundFiles(report, file ,
> "Type","Status");
>                        entityManager.persist(outboundFiles);
>                        transaction.commit();
>                        entityManager.close();
>                } catch(RuntimeException rte) {
>                        System.out.println(rte.getMessage());
>                }
>        }
> }
>
>
> --
> View this message in context:
> http://n2.nabble.com/Nested-Exception-Error-tp2226964p2226964.html
> Sent from the OpenJPA Developers mailing list archive at Nabble.com.
>
>