openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Das, Aditi" <Aditi....@schwab.com>
Subject Does embedded class works only with enhancer?
Date Mon, 20 Aug 2007 00:51:12 GMT
Hi,
 
I have a entity and a emdeddable class as below.
================================================
@Entity(name = "ARTICLE")
public class Article  implements Cloneable,Serializable{
      @Id
     @GeneratedValue(strategy=GenerationType.AUTO)
     private long id;
 
     @Embedded
     private Content content;
 
     @Version
     @Column(name = "VER")
     private long version;
}
 
@Embeddable
public class Content {
     @Lob
     private String content;
 
     public String getContent() {
          return content;
     }
 
     public void setContent(String content) {
          this.content = content;
     }
}
======================================================
 
When I run the below code with enhancer, everything works fine,
==========================================================
  tx.begin();
  Article article =  em.find(Article.class,11);
  article.getContent().setContent("Once upon a time there is a city of
Hamelin!!!");
  tx.commit();
=================================================================
 
But without enhancer, it gives me the below error.
 
------------------------------------------------------------------------
----------------------------------------------------------
Exception in thread "main" <openjpa-0.0.0-runknown fatal store error>
org.apache.openjpa.persistence.RollbackException: no-saved-fields
 at
org.apache.openjpa.persistence.EntityManagerImpl.commit(EntityManagerImp
l.java:420)
 at jpa.ArticleTest.main(ArticleTest.java:24)
Caused by: <openjpa-0.0.0-runknown fatal general error>
org.apache.openjpa.persistence.PersistenceException: no-saved-fields
 at
org.apache.openjpa.kernel.StateManagerImpl.dirtyCheck(StateManagerImpl.j
ava:799)
 at
org.apache.openjpa.kernel.BrokerImpl$ManagedCache.dirtyCheck(BrokerImpl.
java:4649)
 at
org.apache.openjpa.kernel.BrokerImpl$ManagedCache.access$0(BrokerImpl.ja
va:4644)
 at
org.apache.openjpa.kernel.BrokerImpl.hasTransactionalObjects(BrokerImpl.
java:3767)
 at org.apache.openjpa.kernel.BrokerImpl.setDirty(BrokerImpl.java:3884)
 at
org.apache.openjpa.kernel.StateManagerImpl.setPCState(StateManagerImpl.j
ava:207)
 at
org.apache.openjpa.kernel.StateManagerImpl.dirty(StateManagerImpl.java:1
533)
 at
org.apache.openjpa.kernel.StateManagerImpl.dirty(StateManagerImpl.java:1
472)
 at
org.apache.openjpa.kernel.StateManagerImpl.dirtyCheck(StateManagerImpl.j
ava:809)
 at
org.apache.openjpa.kernel.BrokerImpl$ManagedCache.dirtyCheck(BrokerImpl.
java:4649)
 at
org.apache.openjpa.kernel.BrokerImpl$ManagedCache.access$0(BrokerImpl.ja
va:4644)
 at
org.apache.openjpa.kernel.BrokerImpl.hasTransactionalObjects(BrokerImpl.
java:3767)
 at
org.apache.openjpa.kernel.BrokerImpl.getTransactionalStates(BrokerImpl.j
ava:3756)
 at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1898)
 at org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:1879)
 at
org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(BrokerImpl.java:17
97)
 at
org.apache.openjpa.kernel.LocalManagedRuntime.commit(LocalManagedRuntime
.java:81)
 at org.apache.openjpa.kernel.BrokerImpl.commit(BrokerImpl.java:1327)
 at
org.apache.openjpa.kernel.DelegatingBroker.commit(DelegatingBroker.java:
866)
 at
org.apache.openjpa.persistence.EntityManagerImpl.commit(EntityManagerImp
l.java:409)
 ... 1 more
------------------------------------------------------------------------
-----------------------------------------------------------------
 
When I traced back, I found the below code in BrokerImpl(kernel package)
where the embadable stateManager is getting added to the _untracked.
 
       public void add(StateManagerImpl sm) {
            if (!sm.isIntercepting()){
                if (_untracked == null)
                    _untracked = new HashSet();
                _untracked.add(sm);
            }
            ....................
     }
 
If I change the above code to , everything works fine..
 
         public void add(StateManagerImpl sm) {
            if (!sm.isIntercepting() && !sm.isEmbedded()) {
                if (_untracked == null)
                    _untracked = new HashSet();
                _untracked.add(sm);
            }
            ....................
     }
 
 
Not sure whether it is a feature of enhancer or a bug..Or am I missing
out any annotation/property etc.?
 
 
Please let me know,
Aditi
 
 

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message