[Hibernate-JIRA] Created: (HHH-6707) One-to-One mapping with foreign key in target table and foreign key being the primary key fails with Oracle
by Florian Rampp (JIRA)
One-to-One mapping with foreign key in target table and foreign key being the primary key fails with Oracle
-----------------------------------------------------------------------------------------------------------
Key: HHH-6707
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6707
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.6.6
Environment: Oracle 11g, Oracle JDBC 11.2.0.1.0
Reporter: Florian Rampp
Attachments: bugreports-hibernate-oracleUniquePk-1.0-SNAPSHOT-src.zip
When mapping a one-to-one parent/child relationship with the foreign key being in the child table and forming its primary key, in addition to the primary key definition, a unique constraint is generated (due to the one-to-one inverse mapping). A unique constraint and a primary key definition on the same column is not accepted by Oracle. The error is "ORA-02261: such unique or primary key already exists in the table" when creating the schema.
The key entities:
{code:java}
@Entity
public class Parent {
@Id
Long id;
@OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "parent")
Child child;
}
@Entity
public class Child implements Serializable {
@Id
@OneToOne(optional = false)
private Parent parent;
}
{code}
The resulting DDL is:
{code:sql}
create table Child (
parent_id number(19,0) not null,
primary key (parent_id),
unique (parent_id)
)
{code}
This issue is similar to https://hibernate.onjira.com/browse/HBX-978. But I refiled it here since I consider it to be a bug in Hibernate core. Also, I provided a test case that can be used for regression tests. It needs to be executed with the arguments {{-Dhibernate.connection.username=<USERNAME> -Dhibernate.connection.password=<PASSWORD> -Dhibernate.connection.url=<JDBC_URL>}}.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years, 4 months
[Hibernate-JIRA] Created: (HHH-2158) incorrect hql query on one-to-one with property-ref
by Sebastien Cesbron (JIRA)
incorrect hql query on one-to-one with property-ref
----------------------------------------------------
Key: HHH-2158
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2158
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.2.0.ga
Environment: hibernate 3.2.0.ga with firebird 1.5.3 and jaybird 1.5.5 driver on windows XP
Reporter: Sebastien Cesbron
Attachments: testhib.zip
I have a one-to-one relationship with property-ref between Master and Slave2.
I want to find all Master instances that have a null Slave2 instance associated.
To do so my query is
select master from Master master where master.slave2 is null
The sql generated is
select master0_.oid as oid0_, master0_.libelle as libelle0_ from Master master0_ where master0_.oid is null
which seems incorrect. It checks here Master instances with null id (config files are listed below).
If I do my query like this
select master from Master master where master.slave2.oid is null
the generated sql is ok :
select master0_.oid as oid0_, master0_.libelle as libelle0_ from Master master0_, Slave2 slave2x1_ where master0_.oid=slave2x1_.myMaster and (slave2x1_.oid is null)
I have attached a small eclipse project that reproduces the problem
This problem may-be related to the one I have submitted as issue HHH-1849
--
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
13 years, 4 months