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-tp2226952p2226952.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Reply via email to