| |

VerySource

 Forgot password?
 Register
Search
View: 1497|Reply: 12

It turned out all right, but since a trigger was added to the SQL database, I got an error and couldn't figure it out ?

[Copy link]

1

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-2-20 12:00:03
| Show all posts |Read mode
log4j: WARN No appenders could be found for logger (org.jboss.util.NestedThrowable).

log4j: WARN Please initialize the log4j system properly.

org.jboss.tm.JBossTransactionRolledbackException: null; nested exception is:
org.jboss.tm.JBossRollbackException: Unable to commit, tx = TransactionImpl: XidImpl [FormatId = 257, GlobalId = lqgscp / 15, BranchQual =, localId = 15] status = STATUS_NO_TRANSACTION;-nested throwable: (javax.ejb.EJBException: Update failed. Expected one affected row: rowsAffected = 0, id=dyxx.TransinfoPK@3a2b7dd);-nested throwable: (org.jboss.tm.JBossRollbackException: Unable to commit, tx = TransactionImpl: XidImpl [FormatId = 257, GlobalId = Global lqgscp / 15, BranchQual =, localId = 15] status = STATUS_NO_TRANSACTION;-nested throwable: (javax.ejb.EJBException: Update failed. Expected one affected row: rowsAffected = 0, id=dyxx.TransinfoPK@3a2b7dd))

at org.jboss.ejb.plugins.TxInterceptorCMT.throwJBossException (TxInterceptorCMT.java:554)

at org.jboss.ejb.plugins.TxInterceptorCMT.endTransaction (TxInterceptorCMT.java:491)

at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions (TxInterceptorCMT.java:346)

at org.jboss.ejb.plugins.TxInterceptorCMT.invoke (TxInterceptorCMT.java:166)

at org.jboss.ejb.plugins.SecurityInterceptor.invoke (SecurityInterceptor.java:139)

at org.jboss.ejb.plugins.LogInterceptor.invoke (LogInterceptor.java:192)

at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke (ProxyFactoryFinderInterceptor.java:122)

at org.jboss.ejb.SessionContainer.internalInvoke (SessionContainer.java:624)

at org.jboss.ejb.Container.invoke (Container.java:873)

at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke (Method.java:585)

at org.jboss.mx.interceptor.ReflectedDispatcher.invoke (ReflectedDispatcher.java:141)

at org.jboss.mx.server.Invocation.dispatch (Invocation.java:80)

at org.jboss.mx.server.Invocation.invoke (Invocation.java:72)

at org.jboss.mx.server.AbstractMBeanInvoker.invoke (AbstractMBeanInvoker.java:249)

at org.jboss.mx.server.MBeanServerImpl.invoke (MBeanServerImpl.java:644)

at org.jboss.invocation.jrmp.server.JRMPInvoker $ MBeanServerAction.invoke (JRMPInvoker.java:805)

at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke (JRMPInvoker.java:406)

at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke (Method.java:585)

at sun.rmi.server.UnicastServerRef.dispatch (UnicastServerRef.java:294)

at sun.rmi.transport.Transport $ 1.run (Transport.java:153)

at java.security.AccessController.doPrivileged (Native Method)

at sun.rmi.transport.Transport.serviceCall (Transport.java:149)

at sun.rmi.transport.tcp.TCPTransport.handleMessages (TCPTransport.java:466)

at sun.rmi.transport.tcp.TCPTransport $ ConnectionHandler.run (TCPTransport.java:707)

at java.lang.Thread.run (Thread.java:595)

Caused by: org.jboss.tm.JBossRollbackException: Unable to commit, tx = TransactionImpl: XidImpl [FormatId = 257, GlobalId = lqgscp / 15, BranchQual =, localId = 15] status = STATUS_NO_TRANSACTION;-nested throwable: (javax.ejb .EJBException: Update failed. Expected one affected row: rowsAffected = 0, id=dyxx.TransinfoPK@3a2b7dd)

at org.jboss.tm.TransactionImpl.commit (TransactionImpl.java:344)

at org.jboss.ejb.plugins.TxInterceptorCMT.endTransaction (TxInterceptorCMT.java:486)

... 29 more

Caused by: javax.ejb.EJBException: Update failed. Expected one affected row: rowsAffected = 0, id=dyxx.TransinfoPK@3a2b7dd

at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreEntityCommand.execute (JDBCStoreEntityCommand.java:155)

at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.storeEntity (JDBCStoreManager.java:651)

at org.jboss.ejb.plugins.CMPPersistenceManager.storeEntity (CMPPersistenceManager.java:413)

at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.storeEntity (CachedConnectionInterceptor.java:390)

at org.jboss.ejb.EntityContainer.storeEntity (EntityContainer.java:743)

at org.jboss.ejb.GlobalTxEntityMap $ 2.synchronize (GlobalTxEntityMap.java:134)

at org.jboss.ejb.GlobalTxEntityMap $ GlobalTxSynchronization.synchronize (GlobalTxEntityMap.java:253)

at org.jboss.ejb.GlobalTxEntityMap $ GlobalTxSynchronization.beforeCompletion (GlobalTxEntityMap.java:302)

at org.jboss.tm.TransactionImpl.doBeforeCompletion (TransactionImpl.java:1384)

at org.jboss.tm.TransactionImpl.beforePrepare (TransactionImpl.java:1076)

at org.jboss.tm.TransactionImpl.commit (TransactionImpl.java:296)

... 30 more


I tested the trigger in the Query Analyzer and everything works fine. I don't know how to get into the EJB when the problem occurs? After reading some information, I was at a loss. I also look forward to answering the experts here.
Reply

Use magic Report

0

Threads

39

Posts

23.00

Credits

Newbie

Rank: 1

Credits
23.00

 China

Post time: 2020-4-28 12:15:01
| Show all posts
Take your updated SQL operation in EJB to the outside and run it to see if there are any errors.
Reply

Use magic Report

0

Threads

18

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-4-30 03:15:01
| Show all posts
Agree upstairs
Reply

Use magic Report

1

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-5-28 19:00:01
| Show all posts
This is the modified function in EJB:
public void updateTransinfo2 (String substaid, String lineid, String transid,
                               BigDecimal voltagein, Timestamp usedate,
                               String transname, String copyerid,
                               Integer transtypeid, Integer usetype,
                               Integer transcapa, Integer booknum,
                               String transaddr, String producecompany,
                               String producecode, Timestamp producedate,
                               Integer nousedays, Integer compoint,
                               BigDecimal rating) {

    TransinfoPK pk = new TransinfoPK (substaid, lineid, transid);
    try {
      TransinfoRemote ejb = Transinfohome.findByPrimaryKey (pk);

      ejb.setVoltagein (voltagein);
      ejb.setUsedate (usedate);

      ejb.setTransname (transname);
      ejb.setCopyerid (copyerid);
      ejb.setTranstypeid (transtypeid);
      ejb.setUsetype (usetype);

      ejb.setTranscapa (transcapa);

      ejb.setTransaddr (transaddr);
      ejb.setProducecompany (producecompany);
      ejb.setProducecode (producecode);

      ejb.setProducedate (producedate);
      ejb.setNousedays (nousedays);
      ejb.setCompoint (compoint);
      ejb.setRating (rating);
      ejb.setBooknum (booknum);

    }
    catch (RemoteException ex) {
    }
    catch (FinderException ex) {
    }
  }

This is the test terminal I generated in JBUILDER:
  public static void main (String [] args) {
    dyxxSessTestClient1 client = new dyxxSessTestClient1 ();
    dyxxSess test = client.create ();

    String substaid = "01"; // Substation number
    String lineid = "3030"; // Line number
    String transid = "005"; // Transformer ID
    BigDecimal voltagein = new BigDecimal ("36.1"); // Input terminal voltage
    Timestamp usedate = Timestamp.valueOf ("2015-11-11 15: 14: 18.999999911"); // Date of operation

    String transname = "33"; // Transformer name
    String copyerid = "01"; // Number of copy meter
    String charcomid = "02"; // Number of power supply station
    Integer transtypeid = Integer.valueOf (1); // Transformer type
    Integer usetype = Integer.valueOf (0); // Special public flag

    Integer transcapa = Integer.valueOf (33); // Fixed capacity
    Integer booknum = Integer.valueOf (33); // Table number
    String transaddr = "33"; // Installation address
    String producecompany = "33"; // Manufacturer
    String producecode = "33"; // Factory number
    Timestamp producedate = Timestamp.valueOf ("2015-08-08 15: 14: 18.999999911"); // Date of manufacture
    Integer nousedays = Integer.valueOf (33); // number of running days
    Integer compoint = Integer.valueOf (0);
        BigDecimal rating = new BigDecimal ("0.5555");
// BigDecimal rating = null;
        try {
          test.updateTransinfo2 (
              substaid, lineid, transid,
              voltagein, usedate,
              transname, copyerid, transtypeid,
              usetype, transcapa, booknum
              , transaddr,
              producecompany, producecode,
              producedate, nousedays, compoint, rating
              );
        }
        catch (Exception ex) {
          ex.printStackTrace ();
        }

  }

When I commented out ejb.setBooknum (booknum) in EJB's public void updateTransinfo2 (..) {..}; there is no problem in running the entire test terminal, and the remaining fields can also be modified. If there is this sentence, the above error will be reported on the test side.

update transinfo set booknum = 999 where substaid = '01 'and lineid =' 3030 'and transid =' 001 '
This is when I change the field with the trigger separately in the query analyzer, the trigger can work normally

Also hope that masters enlighten me
Reply

Use magic Report

0

Threads

3

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-7-23 14:30:01
| Show all posts
Is there no error if I remove the trigger? Ok?

If yes: try adding commit tran at the end of the trigger!
Reply

Use magic Report

0

Threads

3

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-7-23 14:45:01
| Show all posts
Of course, add before the trigger:
begin tran
Reply

Use magic Report

1

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-7-28 18:30:01
| Show all posts
Here is the trigger,
Executed in the query analyzer alone (that is, to change the field with the trigger), the trigger is fully functional. When I am in the EJB, I comment out the statement related to the trigger (ejb.setBooknum(booknum);) , The entire EJB program is no problem


SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO


/*Create and modify the transformer information trigger*/
ALTER trigger T_update_trans
on transinfo
for update
as
--Out of service transformer, the outage information table is maintained by the trigger
begin
  
  --Modify the transformer table number, the user's table number is maintained by the trigger
  if update(booknum)
  begin
        begin tran trans1
        
  update userinfo set booknum = b.booknum
  from userinfo a,inserted b
  where a.substaid = b.substaid and a.lineid = b.lineid and a.transid = b.transid
  To
  commit tran trans1
  end
end


GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-7-30 19:45:02
| Show all posts
Whether the trigger modifies a table that other programs do not have authority to root
Reply

Use magic Report

1

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-7-31 16:00:01
| Show all posts
I feel as if it is related to EJB.
JBossTransactionRolledbackException This exception may be the key. I searched about this exception, but I did not understand the relevant article
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-12 03:00:01
| Show all posts
update userinfo set userinfo.booknum = b.booknum
  from userinfo a,inserted b
  where a.substaid = b.substaid and a.lineid = b.lineid and a.transid = b.transid
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list