[Persistence, JBoss/CMP, Hibernate, Database] - Update corrupt database
by fbenvegna
I update a EJB Entity and after insert call the record is corrupted...
A value 147.163.0.61 is inserted as 沿47.163.0.61.
The first character is corrupted.
My solution is a persist (with flush) of partial record (with many object attributes insertable=false) and a merge.
I think that problem is many attributes of type java.util.Date. Attributes of type Date are updated but but not inserted.
| @Entity
| @Table(name = "TB_LOG")
| public class Log implements Serializable {
|
| private static final long serialVersionUID = 1L;
|
| @Id
| @Column(name = "OID", updatable = false)
| @SequenceGenerator(name = "SEQUENCE", sequenceName = "SEQ_TB_LOG_WSR", allocationSize = 1)
| @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQUENCE")
| private long oid;
|
| @Column(name = "CLI", nullable = false, updatable = false)
| private String clientAddress;
|
| @Lob
| @Basic(fetch=FetchType.LAZY)
| @Column(name = "SOA_REQ", nullable = true, insertable=false)
| private String request;
|
| @Lob
| @Basic(fetch=FetchType.LAZY)
| @Column(name = "SOA_RES", nullable = true, insertable=false)
| private String response;
|
| @Column(name = "DAT", nullable = true, insertable = false)
| private Date date;
|
| ....
| ....
| }
This is the only corrected method to store object Log (others cause curruption)
| Log log = new Log();
| log.setClientAddress(new String(address.toString())); // non so perchè ma necessita ricreare la stringa
| // altrimenti sulla INSERT del db accade un casino
| // !!! BOOOOO
| em.persist(log);
| em.flush();
|
| log.setDate(date); // non so perchè ma non cambiare l'ordine della persist e della merge, altrimenti i dati
| // su db saranno corrotti!!! BOOO
| log.setRequest(request);
| log.setResponse(response);
|
| em.merge(log);
| em.flush();
|
My configuration is:
- JBoss 4.0.5
- Seam 1.2.1.GA
- Hibernate core updated to 3.2.5
- Oracle Database 8.1.7
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4079625#4079625
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4079625
17Â years, 2Â months
[JBossCache] - Re: Failed to create local transaction; TransactionManager i
by BruceSpringfield
logging on startup :
anonymous wrote : 2007-08-30 15:24:12,800 INFO [STDOUT] - before start
| 2007-08-30 15:24:12,800 INFO [org.jboss.cache.pojo.impl.PojoCacheImpl] PojoCache version: JBossCache 'Habanero' 2.0.0.GA[ $Id: Version.java,v 1.35 2007/08/01 16:52:13 msurtani Exp $]
| 2007-08-30 15:24:12,862 INFO [org.jboss.cache.factories.InterceptorChainFactory] interceptor chain is:
| class org.jboss.cache.interceptors.CallInterceptor
| class org.jboss.cache.interceptors.OptimisticNodeInterceptor
| class org.jboss.cache.interceptors.OptimisticCreateIfNotExistsInterceptor
| class org.jboss.cache.interceptors.OptimisticValidatorInterceptor
| class org.jboss.cache.interceptors.OptimisticLockingInterceptor
| class org.jboss.cache.interceptors.NotificationInterceptor
| class org.jboss.cache.interceptors.TxInterceptor
| class org.jboss.cache.interceptors.CacheMgmtInterceptor
| class org.jboss.cache.interceptors.InvocationContextInterceptor
| 2007-08-30 15:24:12,862 DEBUG [org.jboss.cache.CacheImpl.test-1] Not using an EvictionPolicy
| 2007-08-30 15:24:12,862 INFO [org.jboss.cache.pojo.impl.PojoCacheImpl] PojoCache version: JBossCache 'Habanero' 2.0.0.GA[ $Id: Version.java,v 1.35 2007/08/01 16:52:13 msurtani Exp $]
| 2007-08-30 15:24:12,878 DEBUG [org.jboss.cache.CacheImpl.test-1] failed looking up TransactionManager, will not use transactions
| java.lang.ClassCastException: com.arjuna.ats.jbossatx.jta.TransactionManagerDelegate
| at org.jboss.cache.transaction.JBossTransactionManagerLookup.getTransactionManager(JBossTransactionManagerLookup.java:20)
| at org.jboss.cache.CacheImpl.createTransactionManager(CacheImpl.java:660)
| at org.jboss.cache.CacheImpl.internalStart(CacheImpl.java:726)
| at org.jboss.cache.CacheImpl.start(CacheImpl.java:708)
| at org.jboss.cache.pojo.impl.PojoCacheImpl.start(PojoCacheImpl.java:258)
| at com.jboss.cache.POJOCacheImpl.start(POJOCacheImpl.java:196)
| at com.jboss.cache.POJOCacheImpl.(POJOCacheImpl.java:40)
| at com.jboss.cache.POJOCacheImpl.cacheInstance(POJOCacheImpl.java:49)
| at com.jboss.test.CacheSecondLevelTest.init(CacheSecondLevelTest.java:37)
| at com.jboss.test.CacheSecondLevelTest.start(CacheSecondLevelTest.java:197)
| at com.jboss.test.ControllerServlet.processRequest(ControllerServlet.java:45)
| at com.jboss.test.ControllerServlet.doGet(ControllerServlet.java:19)
| at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
| at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
| at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
| at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
| at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
| at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
| at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
| at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
| at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
| at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
| at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
| at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
| at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
| at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
| at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
| at java.lang.Thread.run(Thread.java:595)
| 2007-08-30 15:24:12,878 DEBUG [org.jboss.cache.CacheImpl.test-1] cache mode is local, will not create the channel
| 2007-08-30 15:24:12,878 INFO [org.jboss.cache.CacheImpl.test-1] JBoss Cache version: JBossCache 'Habanero' 2.0.0.GA[ $Id: Version.java,v 1.35 2007/08/01 16:52:13 msurtani Exp $]
| 2007-08-30 15:24:12,878 INFO [STDOUT] - after start
the local transaction exception occurs as something is attached to the POJO cache :
anonymous wrote : 2007-08-30 15:24:12,925 INFO [STDOUT] Cache Put
| 2007-08-30 15:24:12,925 INFO [STDOUT] ---------------------------------------------
| 2007-08-30 15:24:12,971 TRACE [org.jboss.cache.interceptors.InvocationContextInterceptor] Invoked on cache instance [null] and InvocationContext [InvocationContext{methodCall=MethodName: _get; MethodIdInteger: 26; Args: (/vespa/customers/54321/a4ej9/98iurp, POJOCache.PojoReference, true)transaction=null, globalTransaction=null, optionOverrides=Option{failSilently=false, cacheModeLocal=false, dataVersion=null, suppressLocking=false, forceDataGravitation=true, skipDataGravitation=false}, originLocal=true, txHasMods=false}]
| 2007-08-30 15:24:12,971 TRACE [org.jboss.cache.interceptors.InvocationContextInterceptor] no transaction manager configured, setting tx as null.
| 2007-08-30 15:24:12,971 TRACE [org.jboss.cache.interceptors.InvocationContextInterceptor] Setting up transactional context.
| 2007-08-30 15:24:12,971 TRACE [org.jboss.cache.interceptors.InvocationContextInterceptor] Setting tx as null and gtx as null
| 2007-08-30 15:24:12,971 TRACE [org.jboss.cache.interceptors.TxInterceptor] (null) call on method [MethodName: _get; MethodIdInteger: 26; Args: (/vespa/customers/54321/a4ej9/98iurp, POJOCache.PojoReference, true)]
| 2007-08-30 15:24:12,971 TRACE [org.jboss.cache.interceptors.TxInterceptor] Creating transaction for thread Thread[http-127.0.0.1-8080-1,5,jboss]
| 2007-08-30 15:24:12,971 TRACE [org.jboss.cache.interceptors.InvocationContextInterceptor] Resetting invocation-scope options
| 2007-08-30 15:24:12,971 ERROR [com.jboss.cache.POJOCacheImpl] put()
| java.lang.RuntimeException: java.lang.Exception: Failed to create local transaction; TransactionManager is null
| at org.jboss.cache.CacheImpl.invokeMethod(CacheImpl.java:3951)
| at org.jboss.cache.CacheImpl.get(CacheImpl.java:1441)
| at org.jboss.cache.CacheImpl.get(CacheImpl.java:1415)
| at org.jboss.cache.pojo.impl.InternalHelper.get(InternalHelper.java:92)
| at org.jboss.cache.pojo.impl.InternalHelper.getPojoReference(InternalHelper.java:46)
| at org.jboss.cache.pojo.impl.InternalHelper.getPojo(InternalHelper.java:181)
| at org.jboss.cache.pojo.impl.PojoCacheDelegate.putObjectI(PojoCacheDelegate.java:113)
| at org.jboss.cache.pojo.impl.PojoCacheImpl.putObject(PojoCacheImpl.java:133)
| at org.jboss.cache.pojo.impl.PojoCacheImpl.org$jboss$cache$pojo$impl$PojoCacheImpl$attach$aop(PojoCacheImpl.java:101)
| at org.jboss.cache.pojo.impl.PojoCacheImpl.attach(PojoCacheImpl.java)
| at org.jboss.cache.pojo.impl.PojoCacheImpl.attach(PojoCacheImpl.java:93)
| at com.jboss.cache.POJOCacheImpl.put(POJOCacheImpl.java:62)
| at com.jboss.test.CacheSecondLevelTest.testSecondLevel(CacheSecondLevelTest.java:88)
| at com.jboss.test.CacheSecondLevelTest.start(CacheSecondLevelTest.java:199)
| at com.jboss.test.ControllerServlet.processRequest(ControllerServlet.java:45)
| at com.jboss.test.ControllerServlet.doGet(ControllerServlet.java:19)
| at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
| at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
| at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
| at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
| at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
| at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
| at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
| at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
| at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
| at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
| at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
| at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
| at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
| at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
| at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
| at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
| at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
| at java.lang.Thread.run(Thread.java:595)
| Caused by: java.lang.Exception: Failed to create local transaction; TransactionManager is null
| at org.jboss.cache.interceptors.TxInterceptor.createLocalTx(TxInterceptor.java:946)
| at org.jboss.cache.interceptors.TxInterceptor.handleNonTxMethod(TxInterceptor.java:288)
| at org.jboss.cache.interceptors.TxInterceptor.invoke(TxInterceptor.java:131)
| at org.jboss.cache.interceptors.Interceptor.invoke(Interceptor.java:76)
| at org.jboss.cache.interceptors.CacheMgmtInterceptor.invoke(CacheMgmtInterceptor.java:81)
| at org.jboss.cache.interceptors.Interceptor.invoke(Interceptor.java:76)
| at org.jboss.cache.interceptors.InvocationContextInterceptor.invoke(InvocationContextInterceptor.java:62)
| at org.jboss.cache.CacheImpl.invokeMethod(CacheImpl.java:3939)
| ... 35 more
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4079611#4079611
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4079611
17Â years, 2Â months