change discriminator value at runtime?

I'm working with a hierachy object model with a jpa entity persistance support.

Here the classes model:

User class:

@Entity

@Table(name = "user", catalog = "users")

@NamedQueries({

@NamedQuery(...

})

@Inheritance(strategy= InheritanceType.JOINED)

@DiscriminatorColumn(name = "apType", discriminatorType =

DiscriminatorType.STRING, length = 255)

//@DiscriminatorValue("user")

public class User implements Serializable {

@Transient

protected PropertyChangeSupport changeSupport = new

PropertyChangeSupport(this);

private static final long serialVersionUID = 1L;

@Id

@GeneratedValue(strategy = GenerationType.AUTO)

@Column(name = "id")

private Long id;

@Column(name = "apType")

private String apType;

@Basic(optional = false)

@Column(name = "name")

private String name;

public UsuariDeClaus() {

this.setApType("user");

}

public Long getId() {

return id;

}

public void setId(Long id) {

Long oldId = this.id;

this.id = id;

changeSupport.firePropertyChange("id", oldId, id);

}

public String getApType() {

return apType;

}

public void setApType(String apType) {

this.apType = apType;

}

public...

Read More »

By: StackOverFlow - Wednesday, 14 March

Related Posts