JPA 2.0 OneToOne Mapping Reference an Attribute
Is it possible to reference a single attribute in the referenced entity, in a OneToOne relationship

Example :
       
       @Entity
       public class Country {
        @Id
        private Long countryId;
       @Column(name="code")
       private String countryCode;
      ...
      } 

     @Entity
     public class City {

      @Id
      private Long cityId;
      
       @OneToOne
       @JoinColumn(name="countryId",referencedColumnName="cityId")
        @Column(name="code")
        private String countryCode;
}

With this setup I get the error @Column(s) not allowed on a @OneToOne property. Is it possible to do this in any other way in JPA 2.0

Thx
Sanjay
JPA 2.0 OneToOne Mapping Reference an Attribute
===

Is it possible to reference a single attribute in the referenced entity, in a OneToOne relationship

Example :
       
       @Entity
       public class Country {
        @Id
        private Long countryId;
       @Column(name="code")
       private String countryCode;
      ...
      } 

     @Entity
     public class City {

      @Id
      private Long cityId;
      
       @OneToOne
       @JoinColumn(name="countryId",referencedColumnName="cityId")
        @Column(name="code")
        private String countryCode;
}

With this setup I get the error @Column(s) not allowed on a @OneToOne property. Is it possible to do this in any other way in JPA 2.0

Thx
Sanjay