hibernate - @transactional, wildfly, mysql(innodb) ejb not rolling back -


I know that has been asked many times before but I could not find any answer to my problem.

I have a webpack which uses Windfill 8 as the Confederate problem The problem is that if I remove an exception within my EJB, then the transaction is not brought back.

I know that I annotate my ego with @style and @localbean, this is a per-transaction copy.

<

I have tried the following:

  • It has been checked that DB rolls back a transaction if I write the SQL code in the workspace < / P>

     ; 'BookSevelop' VALUES ('firstname1', 'lastname1') in 'Author' ('First Name', 'Last Name'); Choose from Bookservicewebapp.author; 'BookSevelop' VALUES ('firstname2', 'lastname2') in 'Author' ('First Name', 'Last Name'); Rollback; // Worked!   
  • I
  • Throw an exception which increases the runtime exception and @development exceptions (rollback = True)
  • The exception does not hold on to all
  • I have the @TransactionTimeout (unit = timenNIT.Scnds, value = 5) Have tried to end a time with and wait 6 seconds within the method.

The code under discussion is:

  public list & lt; Long & gt; Bookbooks (list & lt; book & gt; books) {List & lt; Long & gt; Saved books id = new array list & lt; & Gt; (Books.size ()); For (book book: books) {// DB are these writers? & Lt; Author & gt; Received Author = New Array List & lt; Author & gt; (); If (book.getAuthors () == faucet || book.getAuthors (). Size () == 0) {new runtime exception ("no author"); } (Author a: book.getAuthors ()) {// Select all authors with the given attributes list & lt; Author & gt; Buf = getAuthorsByStuff (a.getFirstname (), a.getLastname (), a.getBirthday ()); If (buf.size ()! = 1) {new rollback expanse ("author" + a.getFirstname () + "does not exist"); } Other {fetchedAuthors.add (buf.get (0)); }} Book.setAuthors (Fractured Author); // is the publisher in DB? If (book.getPublisher ()! = Null) {Publisher Pub = book.getPublisher (); // Select all publishers list with the given attributes & lt; Publisher & gt; Buf = getPublishersByStuff (pub.getName (), pub.getPostcode (), pub.getCountrycode ()); If (buf.size ()! = 1) {new rollback expansion ("publisher" + pub.getName () + "does not exist"); } And {book.setPublisher (buf.get (0)); }} //em.persist (book); SavedBooksIds.add (em.merge (book) .getId ()); } Returns saved books ID; }  

Selection code:

  Public list & lt; Author & gt; GetAuthorsByStuff (String Firstname, String Lastname, Date Debt) {return em.createNamedQuery ("Author .getAuthorsByStuff", author.class) .setParameter ("firstname", firstname) .setParameter ("lastname", lastname) .setParameter ("Birthday ", Date) .getResultList (); }   

The error was that the wildfly was configured incorrectly. JTA was to be enabled and to configure an isolation level.

  & lt; Data source jta = "true" jndi-name = "java: jboss / datasources / bookservicewebAppDS" pool-name = "BookServiceWebAppDS" enabled = "true" use-ccm = "false" & gt; & Lt; Connection-URL & gt; JDBC: mysql: // local host: 3306 / bookservicewebapp & lt; / Connection-URL & gt; & Lt; Driver category & gt; Com.mysql.jdbc.Driver & lt; / Driver category & gt; & Lt; Driver & gt; Mysql & lt; / Driver & gt; & Lt; Transaction isolation & gt; TRANSACTION_REPEATABLE_READ & lt; / Transaction isolation & gt; & Lt; Security & gt; & Lt; Username & gt; Username & lt; / Username & gt; & Lt; Password & gt; Password & lt; / Password & gt; & Lt; / Safety & gt; & Lt; Verification & gt; & Lt; Valid-on-match & gt; False & lt; / Valid-on-match & gt; & Lt; Background Verification & gt; False & lt; / Background verification & gt; & Lt; / Verification & gt; & Lt; Statement & gt; & Lt; Share ready-statement & gt; False & lt; / Share-ready-statement & gt; & Lt; / Statement & gt; & Lt; / Data source & gt;  

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -