4 Replies Latest reply on Oct 5, 2005 4:23 AM by nectodev

    @Transient annotation in Embeddable...does not work

    nectodev

      I have an entity bean called State mapped to a table "StateTB". Also StateContext is embedded object mapped to the same table which needs a reference "currentState" to the encapsulating class. Since that reference obviously will not be mapped to any column in the table, I marked the field as @Transient and also the corresponding getter. Following is a simpllified example code...

      @Entity
      @Table(name = "StateTB")
      public class State{
       protected int a;
      
       @Embedded
       protected StateContext stateContext = new StateContext(this);
      
       @Column(name = "colA")
       public getA(){...}
       public setA(){...}
      
       @Embedded
       @AttributeOverrides({
       @AttributeOverride(name = "b", column = @Column(name = "colB"))
       })
       public StateContext getStateContext() {
       return stateContext;
       }
       public void setStateCtx(StateContext stateCtx) {
       this.stateContext = stateCtx;
       }
      }
      
      @Embeddable(access = AccessType.PROPERTY)
      public class StateContext{
      
       protected int b;
      
       @Transient
       protected State currentState;
      
       //constructor
       public StateContext(State state){
       currentState = state;
       }
       public getB(){...}
       public setB(){...}
      
       @Transient
       public getCurrentState(){
       return currentState;
       }
      
       public setCurrentState(State state){
       currentState = state;
       }
      }
      
      


      At deploy time JBoss seems to deploy the entity beans fine UNTIL it starts to "process collection mappings" where it throws the following exception:



      :26:49,845 WARN [ServiceController] Problem creating service jboss.j2ee:service=EJB3,module=pu_services.ejb3
      org.hibernate.MappingException: property not found: currentState
      at org.hibernate.mapping.PersistentClass.getProperty(PersistentClass.java:351)
      at org.hibernate.mapping.PersistentClass.getProperty(PersistentClass.java:356)
      at org.hibernate.cfg.annotations.TableBinder.bindFk(TableBinder.java:115)
      at org.hibernate.cfg.annotations.CollectionBinder.bindCollectionSecondPas.............
      .........
      .........

      and finally in the final summary report at the completion of server start up it throws the following report...


      --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
      ObjectName: jboss.jms:alias=QueueConnectionFactory
      State: FAILED
      Reason: javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out]

      ObjectName: jboss.j2ee:service=EJB3,module=pu_services.ejb3
      State: FAILED
      Reason: org.hibernate.MappingException: property not found: currentState

      ObjectName: jboss.jms:alias=TopicConnectionFactory
      State: FAILED
      Reason: javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out]



      I cant figure what i am doing wrong... Has anyone used @Transient in an embeddable successfully before?

      Any pointer will be greatly appreciated...

      note that this is a spinoff of the original topic http://www.jboss.com/index.html?module=bb&op=viewtopic&t=69811