Announcement Announcement Module
Collapse
No announcement yet.
composite primary key and autogenerated field Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • composite primary key and autogenerated field

    Hi friends,

    I have this configuration....

    Code:
    @Embeddable
    @SequenceGenerator(name="SEQ_PATINMOBILIARIO", sequenceName="PATINMOBILIARIO_ID")
    public class PatInmobiliario_PK implements Serializable{
    	
    	private int codigo;
    	private int declaracion;
    	
    	@Column(name="PI_CODIGO")
    	@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="SEQ_PATINMOBILIARIO")
    	public int getCodigo() {
    		return codigo;
    	}
    	public void setCodigo(int codigo) {
    		this.codigo = codigo;
    	}
    	
    	@Column(name="PI_DE_CODIGO")
    	public int getDeclaracion() {
    		return declaracion;
    	}
    	public void setDeclaracion(int declaracion) {
    		this.declaracion = declaracion;
    	}
    }
    Code:
    @Entity
    @Table(name="TPI_PATINMOBILIARIO")
    public class PatInmobiliario {
    	
    	private PatInmobiliario_PK clave;
    	private String descripcion;
    ...
    	
    	@Id
    	public PatInmobiliario_PK getClave(){
    		return clave;
    	}
    	
    	public void setClave(PatInmobiliario_PK patInmobiliario_PK){
    		this.clave = patInmobiliario_PK;
    	}
    	
    	@Column(name="PI_DESCRIPCION")
    	public String getDescripcion() {
    		return descripcion;
    	}
    	public void setDescripcion(String descripcion) {
    		this.descripcion = descripcion;
    	}
    	
    ....
    
    }
    I read that is possible this configuration in hibernate but the codigo always have the value 0. http://docs.jboss.org/hibernate/anno...ing-identifier point 2.2.3.2.4. Partial identifier generation.

    I'm using Oracle 11g, spring 2.5.6.SEC02, hibernate 3.2 and jboss 4.0.3SP1.

    Thanks a lot!

  • #2
    The following post may help. In particular, setting the database type and Hibernate dialect.

    http://forum.springsource.org/showth...acle-Sequences

    Comment

    Working...
    X