HHH-7571 Formatting test classes and marking OptionalOneToOnePKJCTest/OptionalOneToOneMappedByTest with FailureExpectedForNewMetamodel, because Binder#bindSingularAttribute does throw a NotYeyImplemented exception for ONE_TO_ONE nature.

This commit is contained in:
Hardy Ferentschik 2012-09-10 12:56:30 +02:00
parent e5b57d42e5
commit a4b57ca7fa
9 changed files with 76 additions and 22 deletions

View File

@ -24,7 +24,6 @@
*/
package org.hibernate.test.annotations.onetoone;
/**
* @author Hardy Ferentschik
*/
@ -32,7 +31,7 @@ public class Father {
private int id;
private String name;
public int getId() {
return id;
}

View File

@ -29,6 +29,7 @@ import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.criterion.Restrictions;
import org.hibernate.id.IdentifierGenerationException;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
@ -40,6 +41,7 @@ import static org.junit.Assert.fail;
* @author Emmanuel Bernard
* @author Gail Badner
*/
@FailureExpectedWithNewMetamodel(message = "Needs one to one mapping support. See Binder#bindSingularAttribute")
public class OptionalOneToOneMappedByTest extends BaseCoreFunctionalTestCase {
// @OneToOne(mappedBy="address") with foreign generator

View File

@ -29,6 +29,7 @@ import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.criterion.Restrictions;
import org.hibernate.id.IdentifierGenerationException;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
@ -41,10 +42,11 @@ import static org.junit.Assert.fail;
* @author Emmanuel Bernard
* @author Gail Badner
*/
@FailureExpectedWithNewMetamodel(message = "Needs one to one mapping support. See Binder#bindSingularAttribute")
public class OptionalOneToOnePKJCTest extends BaseCoreFunctionalTestCase {
@Test
@TestForIssue( jiraKey = "HHH-4982")
@TestForIssue(jiraKey = "HHH-4982")
public void testNullBidirForeignIdGenerator() {
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -53,7 +55,7 @@ public class OptionalOneToOnePKJCTest extends BaseCoreFunctionalTestCase {
try {
s.persist( person );
s.flush();
fail( "should have thrown IdentifierGenerationException.");
fail( "should have thrown IdentifierGenerationException." );
}
catch ( IdentifierGenerationException ex ) {
// expected
@ -65,7 +67,7 @@ public class OptionalOneToOnePKJCTest extends BaseCoreFunctionalTestCase {
}
@Test
@TestForIssue( jiraKey = "HHH-4982")
@TestForIssue(jiraKey = "HHH-4982")
public void testNotFoundBidirForeignIdGenerator() {
Session s = openSession();
Transaction tx = s.beginTransaction();
@ -76,7 +78,7 @@ public class OptionalOneToOnePKJCTest extends BaseCoreFunctionalTestCase {
// Hibernate resets the ID to null before executing the foreign generator
s.persist( person );
s.flush();
fail( "should have thrown IdentifierGenerationException.");
fail( "should have thrown IdentifierGenerationException." );
}
catch ( IdentifierGenerationException ex ) {
// expected
@ -89,7 +91,7 @@ public class OptionalOneToOnePKJCTest extends BaseCoreFunctionalTestCase {
// @PrimaryKeyJoinColumn @OneToOne(optional=true) non-foreign generator
@Test
@TestForIssue( jiraKey = "HHH-4982")
@TestForIssue(jiraKey = "HHH-4982")
public void testNotFoundBidirDefaultIdGenerator() {
Session s = openSession();
s.getTransaction().begin();

View File

@ -1,5 +1,28 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.onetoone;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@ -12,9 +35,13 @@ import javax.persistence.PrimaryKeyJoinColumn;
*/
@Entity
public class Owner {
@Id @GeneratedValue private Integer id;
@Id
@GeneratedValue
private Integer id;
@OneToOne(cascade = CascadeType.ALL) @PrimaryKeyJoinColumn private OwnerAddress address;
@OneToOne(cascade = CascadeType.ALL)
@PrimaryKeyJoinColumn
private OwnerAddress address;
public OwnerAddress getAddress() {
return address;

View File

@ -1,5 +1,28 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.onetoone;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
@ -13,11 +36,12 @@ import org.hibernate.annotations.Parameter;
*/
@Entity
public class OwnerAddress {
@Id @GeneratedValue(generator = "fk")
@GenericGenerator(strategy = "foreign", name = "fk", parameters = @Parameter(name="property", value="owner"))
@Id
@GeneratedValue(generator = "fk")
@GenericGenerator(strategy = "foreign", name = "fk", parameters = @Parameter(name = "property", value = "owner"))
private Integer id;
@OneToOne(mappedBy="address")
@OneToOne(mappedBy = "address")
private Owner owner;
public Integer getId() {

View File

@ -38,12 +38,15 @@ import org.hibernate.annotations.Parameter;
*/
@Entity
public class Person {
@Id @GeneratedValue(generator = "fk")
@GenericGenerator(strategy = "foreign", name = "fk", parameters = @Parameter(name="property", value="personAddress"))
@Id
@GeneratedValue(generator = "fk")
@GenericGenerator(strategy = "foreign",
name = "fk",
parameters = @Parameter(name = "property", value = "personAddress"))
private Integer id;
@PrimaryKeyJoinColumn
@OneToOne(optional=true)
@OneToOne(optional = true)
private PersonAddress personAddress;
public Integer getId() {

View File

@ -37,7 +37,7 @@ public class PersonAddress {
@GeneratedValue
private Integer id;
@OneToOne(mappedBy="personAddress")
@OneToOne(mappedBy = "personAddress")
private Person person;
public Integer getId() {

View File

@ -1,4 +1,3 @@
// $Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
@ -24,12 +23,11 @@
*/
package org.hibernate.test.annotations.onetoone;
/**
* @author Hardy Ferentschik
*/
public class Son {
private int id;
private int id;
private String name;

View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="2.0">
<package>org.hibernate.test.annotations.onetoone</package>
<entity class="Father">