0 Replies Latest reply on Jan 9, 2009 10:48 PM by chris.simons

    Embeddable object and JSF; what am I doing wrong?


      All -
      I'm trying to implement a simple embeddable object (EAddress) and store it an entity (Event).


      The problem occurs when I try to then reference this EAddress object from Event, like so: #{cvEvent.address.primaryAddressLine}.


      The exception is that No entity found for query.  I've tried a number of things, including adding implements Serializable onto Address, and also instantiating EAddress when a new Event is created.  I continue to receive the same error.  I should mention that EAddress contains some relationships, which I understand are supported with Hibernate/JPA.


      Here is some source code; thanks for your time.


      @Embeddable
      public class EAddress implements Serializable
      {
          //private Long id;
          
          /** the type of address **/
          @OneToOne(fetch=FetchType.LAZY)
          @JoinColumn(name="ID_ADDRESS_TYPE")
          private AdminValue addressType;
          
          /** primary street address **/
          private String primaryAddressLine;
          
          /** secondary address line, usually used for apartments, condos, etc. **/
          private String secondaryAddressLine;
          
          /** Post Office Box, if applicable **/
          private String postOfficeBox;
          
          /** city **/
          private String city;
          
          /** U.S. state, if applicable **/
          @OneToOne(fetch=FetchType.LAZY)
          @JoinColumn(name="ID_STATE")
          private AdminValue state;
          
          @OneToOne(fetch=FetchType.LAZY)
          @JoinColumn(name="ID_COUNTRY")
          private AdminValue country;
          
          private String zipCode;
          
          private String county;
      }
      



      
      @Entity
      @Table(name="EM_EVENTS")
      @Name("event")
      @Scope(ScopeType.EVENT)
      @NamedQuery(
        name="getAssociatedEventsByParentId",
        query="from Event e where e.parentEvent.id=:pParentEventId and e.active=true order by e.eventName")
      public class Event implements Serializable
      {
             
          /** A test embeddable Address object **/
          @Embedded
          private EAddress address = new EAddress();
        
       // .. code .. //
      
          public EAddress getAddress()
          {
              return address;
          }
      
          public void setAddress(EAddress address)
          {
              this.address = address;
          }
      
          
          
      }