EntityManager doesn't care about INSERT trigger of Oracle XE
------------------------------------------------------------
Key: EJB-381
URL:
http://opensource.atlassian.com/projects/hibernate/browse/EJB-381
Project: Hibernate Entity Manager
Issue Type: Bug
Affects Versions: 3.4.0.GA
Environment: Hibernate EM 3.4.0, Hibernate Annotations 3.4.0, Hibernate Commons
Annotations 3.1.0, Hibernate 3.3.0.SP1, Hibernate Validator 3.1.0.CR2, JDK 1.6.0_07
Reporter: Juergen Zimmermann
I have an abstract entity class with 2 derived concrete classes:
@Entity
@Table(name="kunde")
@Inheritance
@DiscriminatorColumn(name="art", length=1)
@XmlRootElement
@XmlSeeAlso({
Firmenkunde.class,
Privatkunde.class
})
@XmlAccessorType(XmlAccessType.FIELD)
public abstract class Kunde implements java.io.Serializable {
@Id
@GeneratedValue(generator="kunde_sequence_name")
@SequenceGenerator(name="kunde_sequence_name",
sequenceName="kunde_k_id_seq", allocationSize=1)
@Column(name="k_id", nullable=false)
@XmlAttribute(name="id", required=true)
protected Long id = KEINE_ID;
@Version
@XmlTransient
protected int version = ERSTE_VERSION;
@Column(length=32, nullable=false)
@XmlElement(required=true)
protected String nachname = "";
...
@Column(length=32, unique=true)
protected String username = "";
...
}
The table is created as follows:
CREATE TABLE kunde(
k_id NUMBER(16) NOT NULL PRIMARY KEY,
version NUMBER(8) DEFAULT 0,
nachname VARCHAR2(32) NOT NULL,
...
art VARCHAR2(2) DEFAULT 'P',
...
username VARCHAR2(32) NOT NULL UNIQUE,
...
);
Additionally there is this sequence and insert trigger for column username.
CREATE SEQUENCE kunde_k_id_seq START WITH 200 NOMAXVALUE
/
CREATE OR REPLACE TRIGGER kunde_trigger_insert
BEFORE INSERT ON kunde
FOR EACH ROW
BEGIN
:NEW.username := TO_CHAR(:NEW.k_id);
END;
/
New objects are inserted into the database using this code which works fine with
PostgreSQL. However, using Oracle XE the insert trigger isn't considered:
public List<Kunde> insertKunden(List<Kunde> kunden) {
if (kunden == null || kunden.isEmpty()) {
return new ArrayList<Kunde>(0);
}
for (Kunde k: kunden) {
em.persist(k);
}
return kunden;
}
The attribute "username" is null using Oracle XE, but using PostgreSQL it has
the value produced by the INSERT trigger.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira