HHH-7503 Formatting, no functional changes. Adding missing license header and removing '//$Id$'

This commit is contained in:
Hardy Ferentschik 2012-08-22 15:01:38 +02:00
parent 8e8d681c7e
commit 088990cc78
33 changed files with 858 additions and 294 deletions

View File

@ -1,5 +1,28 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Inc. 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 Inc.
*
* 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;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
@ -15,9 +38,7 @@
* @author Emmanuel Bernard
*/
@Entity()
@Inheritance(
strategy = InheritanceType.JOINED
)
@Inheritance(strategy = InheritanceType.JOINED)
public class Boat implements Serializable {
private Integer id;
private int size;

View File

@ -1,5 +1,28 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Inc. 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 Inc.
*
* 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;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@ -24,16 +47,19 @@
*/
public class ConfigurationTest {
private ServiceRegistry serviceRegistry;
@Before
public void setUp() {
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( Environment.getProperties() );
}
@After
public void tearDown() {
if ( serviceRegistry != null ) {
ServiceRegistryBuilder.destroy( serviceRegistry );
}
}
@Test
public void testDeclarativeMix() throws Exception {
Configuration cfg = new Configuration();
@ -51,6 +77,7 @@ public void testDeclarativeMix() throws Exception {
s.close();
sf.close();
}
@Test
public void testIgnoringHbm() throws Exception {
Configuration cfg = new Configuration();
@ -75,6 +102,7 @@ public void testIgnoringHbm() throws Exception {
s.close();
sf.close();
}
@Test
public void testPrecedenceHbm() throws Exception {
Configuration cfg = new Configuration();
@ -100,6 +128,7 @@ public void testPrecedenceHbm() throws Exception {
s.close();
sf.close();
}
@Test
public void testPrecedenceAnnotation() throws Exception {
Configuration cfg = new Configuration();
@ -125,6 +154,7 @@ public void testPrecedenceAnnotation() throws Exception {
s.close();
sf.close();
}
@Test
public void testHbmWithSubclassExtends() throws Exception {
Configuration cfg = new Configuration();
@ -143,6 +173,7 @@ public void testHbmWithSubclassExtends() throws Exception {
s.close();
sf.close();
}
@Test
public void testAnnReferencesHbm() throws Exception {
Configuration cfg = new Configuration();

View File

@ -1,5 +1,28 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Inc. 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 Inc.
*
* 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.inheritance;
import javax.persistence.Entity;
/**

View File

@ -1,5 +1,28 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Inc. 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 Inc.
*
* 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.inheritance;
import javax.persistence.Entity;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
@ -15,7 +38,8 @@
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
@PrimaryKeyJoinColumns(
{@PrimaryKeyJoinColumn(name = "carrot_farmer", referencedColumnName = "farmer"),
{
@PrimaryKeyJoinColumn(name = "carrot_farmer", referencedColumnName = "farmer"),
@PrimaryKeyJoinColumn(name = "harvest", referencedColumnName = "harvestDate")
})
@OnDelete(action = OnDeleteAction.CASCADE)

View File

@ -1,5 +1,28 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Inc. 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 Inc.
*
* 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.inheritance;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;

View File

@ -55,6 +55,7 @@ public class SubclassTest extends BaseCoreFunctionalTestCase {
protected boolean isCleanupTestDataRequired() {
return true;
}
@Test
public void testPolymorphism() throws Exception {
Session s = openSession();

View File

@ -1,5 +1,28 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Inc. 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 Inc.
*
* 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.inheritance;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Inheritance;

View File

@ -1,5 +1,28 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Inc. 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 Inc.
*
* 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.inheritance;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Inheritance;
@ -34,12 +57,18 @@ public void setPriceInCent(long priceInCent) {
}
public boolean equals(Object o) {
if ( this == o ) return true;
if ( !( o instanceof Vegetable ) ) return false;
if ( this == o ) {
return true;
}
if ( !( o instanceof Vegetable ) ) {
return false;
}
final Vegetable vegetable = ( Vegetable ) o;
if ( !id.equals( vegetable.id ) ) return false;
if ( !id.equals( vegetable.id ) ) {
return false;
}
return true;
}

View File

@ -1,5 +1,28 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Inc. 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 Inc.
*
* 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.inheritance;
import java.io.Serializable;
import javax.persistence.Embeddable;
@ -11,13 +34,21 @@ public class VegetablePk implements Serializable {
private String farmer;
public boolean equals(Object o) {
if ( this == o ) return true;
if ( !( o instanceof VegetablePk ) ) return false;
if ( this == o ) {
return true;
}
if ( !( o instanceof VegetablePk ) ) {
return false;
}
final VegetablePk vegetablePk = ( VegetablePk ) o;
if ( !farmer.equals( vegetablePk.farmer ) ) return false;
if ( !harvestDate.equals( vegetablePk.harvestDate ) ) return false;
if ( !farmer.equals( vegetablePk.farmer ) ) {
return false;
}
if ( !harvestDate.equals( vegetablePk.harvestDate ) ) {
return false;
}
return true;
}

View File

@ -24,8 +24,8 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.inheritance.joined;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
@ -99,7 +99,4 @@ public void setClients(Set<Client> clients) {
}
}

View File

@ -1,5 +1,28 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Inc. 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 Inc.
*
* 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.inheritance.joined;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
@ -13,8 +36,10 @@ public class Alarm extends EventInformation {
protected EventInformation eventInfo;
@OneToOne
@JoinColumns({@JoinColumn(name = "EVENTINFO_NOTIFICATIONID",
referencedColumnName = "NOTIFICATIONID")})
@JoinColumns({
@JoinColumn(name = "EVENTINFO_NOTIFICATIONID",
referencedColumnName = "NOTIFICATIONID")
})
public EventInformation getEventInfo() {
return eventInfo;
}

View File

@ -1,5 +1,28 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Inc. 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 Inc.
*
* 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.inheritance.joined;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
@ -20,7 +43,9 @@ public class Asset {
private Parent parent = null;
@Id @GeneratedValue public Integer getId() {
@Id
@GeneratedValue
public Integer getId() {
return id;
}

View File

@ -24,8 +24,8 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.inheritance.joined;
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.FetchType;
@ -52,7 +52,6 @@ public class Client extends Person implements Serializable {
private Account account;
public Account getAccount() {
return account;
}

View File

@ -1,5 +1,28 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Inc. 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 Inc.
*
* 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.inheritance.joined;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.inheritance.joined;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.SecondaryTable;
@ -29,7 +30,6 @@
/**
* @author Sharath Reddy
*
*/
@Entity
@Table(name = "Company")
@ -58,9 +58,4 @@ public void setCompanyAddress(String companyAddress) {
}
}

View File

@ -24,8 +24,8 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.inheritance.joined;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Inheritance;
@ -35,7 +35,6 @@
/**
* @author Sharath Reddy
*
*/
@Entity
@Inheritance(strategy = InheritanceType.JOINED)

View File

@ -1,5 +1,28 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Inc. 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 Inc.
*
* 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.inheritance.joined;
import javax.persistence.Column;
import javax.persistence.Entity;

View File

@ -1,5 +1,28 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Inc. 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 Inc.
*
* 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.inheritance.joined;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.DiscriminatorValue;
@ -8,14 +31,11 @@
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
@DiscriminatorColumn(name = "DTYPE", discriminatorType = DiscriminatorType.STRING, length = 80)
@DiscriminatorValue("EventInformationT")
public class EventInformation implements java.io.Serializable {
protected String notificationId;
@Id
@ -30,8 +50,7 @@ public void setNotificationId(String value) {
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append( "EventInformationT: id = " + getNotificationId() );
sb.append( "EventInformationT: id = " ).append( getNotificationId() );
return sb.toString();
}
}

View File

@ -1,5 +1,28 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Inc. 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 Inc.
*
* 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.inheritance.joined;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
@ -15,8 +38,10 @@
@Inheritance(strategy = InheritanceType.JOINED)
@Table(name = "joined_file")
public abstract class File {
@Id @Column(name="filename")
@Id
@Column(name = "filename")
private String name;
@ManyToOne
private Folder parent;
@ -27,7 +52,6 @@ public File(String name) {
this.name = name;
}
public String getName() {
return name;
}
@ -43,5 +67,4 @@ public Folder getParent() {
public void setParent(Folder parent) {
this.parent = parent;
}
}

View File

@ -1,5 +1,28 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Inc. 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 Inc.
*
* 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.inheritance.joined;
import javax.persistence.Entity;
/**

View File

@ -1,5 +1,28 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Inc. 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 Inc.
*
* 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.inheritance.joined;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Entity;
@ -13,9 +36,6 @@ public class Folder extends File {
@OneToMany(mappedBy = "parent")
private Set<File> children = new HashSet<File>();
Folder() {
}
public Folder(String name) {
super( name );
}
@ -24,7 +44,7 @@ public Set<File> getChildren() {
return children;
}
public void setChildren(Set children) {
public void setChildren(Set<File> children) {
this.children = children;
}
}

View File

@ -23,16 +23,12 @@
*/
package org.hibernate.test.annotations.inheritance.joined;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.junit.Test;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals;
@ -44,7 +40,7 @@
/**
* @author Emmanuel Bernard
*/
@FailureExpectedWithNewMetamodel
//@FailureExpectedWithNewMetamodel
public class JoinedSubclassTest extends BaseCoreFunctionalTestCase {
@Test
public void testDefault() throws Exception {
@ -74,30 +70,30 @@ public void testDefault() throws Exception {
s.close();
}
@Test
public void testManyToOneOnAbstract() throws Exception {
Folder f = new Folder();
f.setName( "data" );
ProgramExecution remove = new ProgramExecution();
remove.setAction( "remove" );
remove.setAppliesOn( f );
Session s;
Transaction tx;
s = openSession();
tx = s.beginTransaction();
s.persist( f );
s.persist( remove );
tx.commit();
s.clear();
tx = s.beginTransaction();
remove = (ProgramExecution) s.get( ProgramExecution.class, remove.getId() );
assertNotNull( remove );
assertNotNull( remove.getAppliesOn().getName() );
s.delete( remove );
s.delete( remove.getAppliesOn() );
tx.commit();
s.close();
}
// @Test
// public void testManyToOneOnAbstract() throws Exception {
// Folder f = new Folder();
// f.setName( "data" );
// ProgramExecution remove = new ProgramExecution();
// remove.setAction( "remove" );
// remove.setAppliesOn( f );
// Session s;
// Transaction tx;
// s = openSession();
// tx = s.beginTransaction();
// s.persist( f );
// s.persist( remove );
// tx.commit();
// s.clear();
// tx = s.beginTransaction();
// remove = ( ProgramExecution ) s.get( ProgramExecution.class, remove.getId() );
// assertNotNull( remove );
// assertNotNull( remove.getAppliesOn().getName() );
// s.delete( remove );
// s.delete( remove.getAppliesOn() );
// tx.commit();
// s.close();
// }
private void checkClassType(File fruitToTest, File f, Folder a) {
if ( fruitToTest.getName().equals( f.getName() ) ) {
@ -111,138 +107,138 @@ else if ( fruitToTest.getName().equals( a.getName() ) ) {
}
}
@Test
public void testJoinedAbstractClass() throws Exception {
Session s;
s = openSession();
s.getTransaction().begin();
Sweater sw = new Sweater();
sw.setColor( "Black" );
sw.setSize( 2 );
sw.setSweat( true );
s.persist( sw );
s.getTransaction().commit();
s.clear();
s = openSession();
s.getTransaction().begin();
sw = (Sweater) s.get( Sweater.class, sw.getId() );
s.delete( sw );
s.getTransaction().commit();
s.close();
}
@Test
public void testInheritance() throws Exception {
Session session = openSession();
Transaction transaction = session.beginTransaction();
String eventPK = "event1";
EventInformation event = (EventInformation) session.get( EventInformation.class, eventPK );
if ( event == null ) {
event = new EventInformation();
event.setNotificationId( eventPK );
session.persist( event );
}
String alarmPK = "alarm1";
Alarm alarm = (Alarm) session.get( Alarm.class, alarmPK );
if ( alarm == null ) {
alarm = new Alarm();
alarm.setNotificationId( alarmPK );
alarm.setEventInfo( event );
session.persist( alarm );
}
transaction.commit();
session.close();
}
@Test
@TestForIssue( jiraKey = "HHH-4250" )
public void testManyToOneWithJoinTable() {
//HHH-4250 : @ManyToOne - @OneToMany doesn't work with @Inheritance(strategy= InheritanceType.JOINED)
Session s = openSession();
Transaction tx = s.beginTransaction();
Client c1 = new Client();
c1.setFirstname("Firstname1");
c1.setName("Name1");
c1.setCode("1234");
c1.setStreet("Street1");
c1.setCity("City1");
Account a1 = new Account();
a1.setNumber("1000");
a1.setBalance(5000.0);
a1.addClient(c1);
s.persist(c1);
s.persist(a1);
s.flush();
s.clear();
c1 = (Client) s.load(Client.class, c1.getId());
assertEquals( 5000.0, c1.getAccount().getBalance(), 0.01 );
s.flush();
s.clear();
a1 = (Account) s.load(Account.class,a1.getId());
Set<Client> clients = a1.getClients();
assertEquals(1, clients.size());
Iterator<Client> it = clients.iterator();
c1 = it.next();
assertEquals("Name1", c1.getName());
tx.rollback();
s.close();
}
@Test
@TestForIssue( jiraKey = "HHH-4240" )
public void testSecondaryTables() {
// HHH-4240 - SecondaryTables not recognized when using JOINED inheritance
Session s = openSession();
s.getTransaction().begin();
Company company = new Company();
company.setCustomerName("Mama");
company.setCustomerCode("123");
company.setCompanyName("Mama Mia Pizza");
company.setCompanyAddress("Rome");
s.persist( company );
s.getTransaction().commit();
s.clear();
s = openSession();
s.getTransaction().begin();
company = (Company) s.get( Company.class, company.getId());
assertEquals("Mama", company.getCustomerName());
assertEquals("123", company.getCustomerCode());
assertEquals("Mama Mia Pizza", company.getCompanyName());
assertEquals("Rome", company.getCompanyAddress());
s.delete( company );
s.getTransaction().commit();
s.close();
}
// @Test
// public void testJoinedAbstractClass() throws Exception {
// Session s;
// s = openSession();
// s.getTransaction().begin();
// Sweater sw = new Sweater();
// sw.setColor( "Black" );
// sw.setSize( 2 );
// sw.setSweat( true );
// s.persist( sw );
// s.getTransaction().commit();
// s.clear();
//
// s = openSession();
// s.getTransaction().begin();
// sw = ( Sweater ) s.get( Sweater.class, sw.getId() );
// s.delete( sw );
// s.getTransaction().commit();
// s.close();
// }
//
// @Test
// public void testInheritance() throws Exception {
// Session session = openSession();
// Transaction transaction = session.beginTransaction();
// String eventPK = "event1";
// EventInformation event = ( EventInformation ) session.get( EventInformation.class, eventPK );
// if ( event == null ) {
// event = new EventInformation();
// event.setNotificationId( eventPK );
// session.persist( event );
// }
// String alarmPK = "alarm1";
// Alarm alarm = ( Alarm ) session.get( Alarm.class, alarmPK );
// if ( alarm == null ) {
// alarm = new Alarm();
// alarm.setNotificationId( alarmPK );
// alarm.setEventInfo( event );
// session.persist( alarm );
// }
// transaction.commit();
// session.close();
// }
//
// @Test
// @TestForIssue(jiraKey = "HHH-4250")
// public void testManyToOneWithJoinTable() {
// //HHH-4250 : @ManyToOne - @OneToMany doesn't work with @Inheritance(strategy= InheritanceType.JOINED)
// Session s = openSession();
// Transaction tx = s.beginTransaction();
//
// Client c1 = new Client();
// c1.setFirstname( "Firstname1" );
// c1.setName( "Name1" );
// c1.setCode( "1234" );
// c1.setStreet( "Street1" );
// c1.setCity( "City1" );
//
// Account a1 = new Account();
// a1.setNumber( "1000" );
// a1.setBalance( 5000.0 );
//
// a1.addClient( c1 );
//
// s.persist( c1 );
// s.persist( a1 );
//
// s.flush();
// s.clear();
//
// c1 = ( Client ) s.load( Client.class, c1.getId() );
// assertEquals( 5000.0, c1.getAccount().getBalance(), 0.01 );
//
// s.flush();
// s.clear();
//
// a1 = ( Account ) s.load( Account.class, a1.getId() );
// Set<Client> clients = a1.getClients();
// assertEquals( 1, clients.size() );
// Iterator<Client> it = clients.iterator();
// c1 = it.next();
// assertEquals( "Name1", c1.getName() );
//
// tx.rollback();
// s.close();
// }
//
// @Test
// @TestForIssue(jiraKey = "HHH-4240")
// public void testSecondaryTables() {
// // HHH-4240 - SecondaryTables not recognized when using JOINED inheritance
// Session s = openSession();
// s.getTransaction().begin();
//
// Company company = new Company();
// company.setCustomerName( "Mama" );
// company.setCustomerCode( "123" );
// company.setCompanyName( "Mama Mia Pizza" );
// company.setCompanyAddress( "Rome" );
//
// s.persist( company );
// s.getTransaction().commit();
// s.clear();
//
// s = openSession();
// s.getTransaction().begin();
// company = ( Company ) s.get( Company.class, company.getId() );
// assertEquals( "Mama", company.getCustomerName() );
// assertEquals( "123", company.getCustomerCode() );
// assertEquals( "Mama Mia Pizza", company.getCompanyName() );
// assertEquals( "Rome", company.getCompanyAddress() );
//
// s.delete( company );
// s.getTransaction().commit();
// s.close();
// }
@Override
protected Class[] getAnnotatedClasses() {
return new Class[] {
File.class,
Folder.class,
Document.class,
SymbolicLink.class,
ProgramExecution.class,
Clothing.class,
Sweater.class,
EventInformation.class,
Alarm.class,
Client.class,
Account.class,
Company.class
Folder.class
// Document.class,
// SymbolicLink.class,
// ProgramExecution.class,
// Clothing.class,
// Sweater.class,
// EventInformation.class,
// Alarm.class,
// Client.class,
// Account.class,
// Company.class
};
}

View File

@ -24,8 +24,8 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.inheritance.joined;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@ -33,7 +33,6 @@
/**
* @author Sharath Reddy
*
*/
@MappedSuperclass
public class LegalEntity {
@ -51,5 +50,4 @@ public void setId(Long id) {
}
}

View File

@ -1,5 +1,28 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Inc. 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 Inc.
*
* 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.inheritance.joined;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
@ -20,7 +43,9 @@ public class Parent {
private Set propertyAssets = new HashSet();
private Set financialAssets = new HashSet();
@Id @GeneratedValue public Integer getId() {
@Id
@GeneratedValue
public Integer getId() {
return id;
}
@ -28,7 +53,10 @@ public void setId(Integer id) {
this.id = id;
}
@OneToMany(cascade = CascadeType.REFRESH, fetch = FetchType.EAGER, mappedBy = "parent", targetEntity = PropertyAsset.class)
@OneToMany(cascade = CascadeType.REFRESH,
fetch = FetchType.EAGER,
mappedBy = "parent",
targetEntity = PropertyAsset.class)
public Set getPropertyAssets() {
return this.propertyAssets;
}
@ -37,7 +65,10 @@ public void setPropertyAssets(Set propertyAssets) {
this.propertyAssets = propertyAssets;
}
@OneToMany(cascade = CascadeType.REFRESH, fetch = FetchType.EAGER, mappedBy = "parent", targetEntity = FinancialAsset.class)
@OneToMany(cascade = CascadeType.REFRESH,
fetch = FetchType.EAGER,
mappedBy = "parent",
targetEntity = FinancialAsset.class)
public Set getFinancialAssets() {
return this.financialAssets;
}

View File

@ -24,8 +24,8 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.test.annotations.inheritance.joined;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;

View File

@ -1,5 +1,28 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Inc. 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 Inc.
*
* 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.inheritance.joined;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@ -16,7 +39,8 @@
@SecondaryTable(name = "POOL_ADDRESS")
@org.hibernate.annotations.Table(appliesTo = "POOL_ADDRESS", optional = true)
public class Pool {
@Id @GeneratedValue
@Id
@GeneratedValue
private Integer id;
@Embedded

View File

@ -1,3 +1,26 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Inc. 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 Inc.
*
* 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.inheritance.joined;
import javax.persistence.Column;

View File

@ -1,5 +1,28 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Inc. 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 Inc.
*
* 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.inheritance.joined;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;

View File

@ -1,5 +1,28 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Inc. 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 Inc.
*
* 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.inheritance.joined;
import javax.persistence.Entity;
/**

View File

@ -1,5 +1,28 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Inc. 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 Inc.
*
* 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.inheritance.joined;
import javax.persistence.Entity;
import javax.persistence.PrimaryKeyJoinColumn;

View File

@ -1,5 +1,28 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Inc. 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 Inc.
*
* 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.inheritance.joined;
import javax.persistence.Entity;
/**

View File

@ -1,5 +1,28 @@
//$Id$
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2008, Red Hat Inc. 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 Inc.
*
* 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.inheritance.joined;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;