HHH-5794 Adding/Updating license headers
This commit is contained in:
parent
66f7018b9d
commit
e5da3bf149
|
@ -22,8 +22,6 @@
|
|||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
// $Id$
|
||||
|
||||
package org.hibernate.cfg.annotations.reflection;
|
||||
|
||||
import java.beans.Introspector;
|
||||
|
@ -1349,7 +1347,7 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
|
|||
}
|
||||
|
||||
private AssociationOverrides getAssociationOverrides(Element tree, XMLContext.Default defaults) {
|
||||
List<AssociationOverride> attributes = (List<AssociationOverride>) buildAssociationOverrides( tree );
|
||||
List<AssociationOverride> attributes = buildAssociationOverrides( tree );
|
||||
if ( defaults.canUseJavaAnnotations() ) {
|
||||
AssociationOverride annotation = getJavaAnnotation( AssociationOverride.class );
|
||||
addAssociationOverrideIfNeeded( annotation, attributes );
|
||||
|
@ -1565,7 +1563,7 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
|
|||
}
|
||||
|
||||
private SqlResultSetMappings getSqlResultSetMappings(Element tree, XMLContext.Default defaults) {
|
||||
List<SqlResultSetMapping> results = (List<SqlResultSetMapping>) buildSqlResultsetMappings( tree, defaults );
|
||||
List<SqlResultSetMapping> results = buildSqlResultsetMappings( tree, defaults );
|
||||
if ( defaults.canUseJavaAnnotations() ) {
|
||||
SqlResultSetMapping annotation = getJavaAnnotation( SqlResultSetMapping.class );
|
||||
addSqlResultsetMappingIfNeeded( annotation, results );
|
||||
|
|
|
@ -1,10 +1,34 @@
|
|||
package org.hibernate.test.annotations.xml.ejb3;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class Company {
|
||||
int id;
|
||||
Map organization = new HashMap();
|
||||
Map conferenceRoomExtensions = new HashMap();
|
||||
}
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by
|
||||
* third-party contributors as indicated by either @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.xml.ejb3;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class Company {
|
||||
int id;
|
||||
Map organization = new HashMap();
|
||||
Map conferenceRoomExtensions = new HashMap();
|
||||
}
|
||||
|
|
|
@ -1,122 +1,144 @@
|
|||
//$Id$
|
||||
package org.hibernate.test.annotations.xml.ejb3;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.Transaction;
|
||||
import org.hibernate.dialect.PostgreSQLDialect;
|
||||
import org.hibernate.metadata.ClassMetadata;
|
||||
import org.hibernate.metadata.CollectionMetadata;
|
||||
import org.hibernate.persister.collection.BasicCollectionPersister;
|
||||
import org.hibernate.test.annotations.TestCase;
|
||||
import org.hibernate.testing.junit.SkipForDialect;
|
||||
import org.hibernate.tuple.entity.EntityMetamodel;
|
||||
|
||||
/**
|
||||
* @author Emmanuel Bernard
|
||||
*/
|
||||
public class Ejb3XmlTest extends TestCase {
|
||||
@SkipForDialect(value = {PostgreSQLDialect.class}, comment = "postgresql jdbc driver does not implement the setQueryTimeout method")
|
||||
public void testEjb3Xml() throws Exception {
|
||||
Session s = openSession();
|
||||
Transaction tx = s.beginTransaction();
|
||||
CarModel model = new CarModel();
|
||||
model.setYear( new Date() );
|
||||
Manufacturer manufacturer = new Manufacturer();
|
||||
//s.persist( manufacturer );
|
||||
model.setManufacturer( manufacturer );
|
||||
manufacturer.getModels().add( model );
|
||||
s.persist( model );
|
||||
s.flush();
|
||||
s.clear();
|
||||
|
||||
model.setYear( new Date() );
|
||||
manufacturer = (Manufacturer) s.get( Manufacturer.class, manufacturer.getId() );
|
||||
List<Model> cars = s.getNamedQuery( "allModelsPerManufacturer" )
|
||||
.setParameter( "manufacturer", manufacturer )
|
||||
.list();
|
||||
assertEquals( 1, cars.size() );
|
||||
for ( Model car : cars ) {
|
||||
assertNotNull( car.getManufacturer() );
|
||||
s.delete( manufacturer );
|
||||
s.delete( car );
|
||||
}
|
||||
tx.rollback();
|
||||
s.close();
|
||||
}
|
||||
|
||||
public void testXMLEntityHandled() throws Exception {
|
||||
Session s = openSession();
|
||||
s.getTransaction().begin();
|
||||
Lighter l = new Lighter();
|
||||
l.name = "Blue";
|
||||
l.power = "400F";
|
||||
s.persist( l );
|
||||
s.flush();
|
||||
s.getTransaction().rollback();
|
||||
s.close();
|
||||
}
|
||||
|
||||
public void testXmlDefaultOverriding() throws Exception {
|
||||
Session s = openSession();
|
||||
Transaction tx = s.beginTransaction();
|
||||
Manufacturer manufacturer = new Manufacturer();
|
||||
s.persist( manufacturer );
|
||||
s.flush();
|
||||
s.clear();
|
||||
|
||||
assertEquals( 1, s.getNamedQuery( "manufacturer.findAll" ).list().size() );
|
||||
tx.rollback();
|
||||
s.close();
|
||||
}
|
||||
|
||||
public void testMapXMLSupport() throws Exception {
|
||||
Session s = openSession();
|
||||
SessionFactory sf = s.getSessionFactory();
|
||||
Transaction tx = s.beginTransaction();
|
||||
|
||||
// Verify that we can persist an object with a couple Map mappings
|
||||
VicePresident vpSales = new VicePresident();
|
||||
vpSales.name = "Dwight";
|
||||
Company company = new Company();
|
||||
company.conferenceRoomExtensions.put("8932", "x1234");
|
||||
company.organization.put("sales", vpSales);
|
||||
s.persist( company );
|
||||
s.flush();
|
||||
s.clear();
|
||||
|
||||
// For the element-collection, check that the orm.xml entries are honored.
|
||||
// This includes: map-key-column/column/collection-table/join-column
|
||||
BasicCollectionPersister confRoomMeta = (BasicCollectionPersister) sf.getCollectionMetadata(Company.class.getName() + ".conferenceRoomExtensions");
|
||||
assertEquals("company_id", confRoomMeta.getKeyColumnNames()[0]);
|
||||
assertEquals("phone_extension", confRoomMeta.getElementColumnNames()[0]);
|
||||
assertEquals("room_number", confRoomMeta.getIndexColumnNames()[0]);
|
||||
assertEquals("phone_extension_lookup", confRoomMeta.getTableName());
|
||||
tx.rollback();
|
||||
s.close();
|
||||
}
|
||||
|
||||
protected Class[] getAnnotatedClasses() {
|
||||
return new Class[]{
|
||||
CarModel.class,
|
||||
Manufacturer.class,
|
||||
Model.class,
|
||||
Light.class
|
||||
//Lighter.class xml only entuty
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String[] getXmlFiles() {
|
||||
return new String[]{
|
||||
"org/hibernate/test/annotations/xml/ejb3/orm.xml",
|
||||
"org/hibernate/test/annotations/xml/ejb3/orm2.xml",
|
||||
"org/hibernate/test/annotations/xml/ejb3/orm3.xml",
|
||||
"org/hibernate/test/annotations/xml/ejb3/orm4.xml"
|
||||
};
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by
|
||||
* third-party contributors as indicated by either @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.xml.ejb3;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.Transaction;
|
||||
import org.hibernate.dialect.PostgreSQLDialect;
|
||||
import org.hibernate.persister.collection.BasicCollectionPersister;
|
||||
import org.hibernate.test.annotations.TestCase;
|
||||
import org.hibernate.testing.junit.SkipForDialect;
|
||||
|
||||
/**
|
||||
* @author Emmanuel Bernard
|
||||
*/
|
||||
public class Ejb3XmlTest extends TestCase {
|
||||
@SkipForDialect(value = { PostgreSQLDialect.class },
|
||||
comment = "postgresql jdbc driver does not implement the setQueryTimeout method")
|
||||
public void testEjb3Xml() throws Exception {
|
||||
Session s = openSession();
|
||||
Transaction tx = s.beginTransaction();
|
||||
CarModel model = new CarModel();
|
||||
model.setYear( new Date() );
|
||||
Manufacturer manufacturer = new Manufacturer();
|
||||
//s.persist( manufacturer );
|
||||
model.setManufacturer( manufacturer );
|
||||
manufacturer.getModels().add( model );
|
||||
s.persist( model );
|
||||
s.flush();
|
||||
s.clear();
|
||||
|
||||
model.setYear( new Date() );
|
||||
manufacturer = (Manufacturer) s.get( Manufacturer.class, manufacturer.getId() );
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Model> cars = s.getNamedQuery( "allModelsPerManufacturer" )
|
||||
.setParameter( "manufacturer", manufacturer )
|
||||
.list();
|
||||
assertEquals( 1, cars.size() );
|
||||
for ( Model car : cars ) {
|
||||
assertNotNull( car.getManufacturer() );
|
||||
s.delete( manufacturer );
|
||||
s.delete( car );
|
||||
}
|
||||
tx.rollback();
|
||||
s.close();
|
||||
}
|
||||
|
||||
public void testXMLEntityHandled() throws Exception {
|
||||
Session s = openSession();
|
||||
s.getTransaction().begin();
|
||||
Lighter l = new Lighter();
|
||||
l.name = "Blue";
|
||||
l.power = "400F";
|
||||
s.persist( l );
|
||||
s.flush();
|
||||
s.getTransaction().rollback();
|
||||
s.close();
|
||||
}
|
||||
|
||||
public void testXmlDefaultOverriding() throws Exception {
|
||||
Session s = openSession();
|
||||
Transaction tx = s.beginTransaction();
|
||||
Manufacturer manufacturer = new Manufacturer();
|
||||
s.persist( manufacturer );
|
||||
s.flush();
|
||||
s.clear();
|
||||
|
||||
assertEquals( 1, s.getNamedQuery( "manufacturer.findAll" ).list().size() );
|
||||
tx.rollback();
|
||||
s.close();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testMapXMLSupport() throws Exception {
|
||||
Session s = openSession();
|
||||
SessionFactory sf = s.getSessionFactory();
|
||||
Transaction tx = s.beginTransaction();
|
||||
|
||||
// Verify that we can persist an object with a couple Map mappings
|
||||
VicePresident vpSales = new VicePresident();
|
||||
vpSales.name = "Dwight";
|
||||
Company company = new Company();
|
||||
company.conferenceRoomExtensions.put( "8932", "x1234" );
|
||||
company.organization.put( "sales", vpSales );
|
||||
s.persist( company );
|
||||
s.flush();
|
||||
s.clear();
|
||||
|
||||
// For the element-collection, check that the orm.xml entries are honored.
|
||||
// This includes: map-key-column/column/collection-table/join-column
|
||||
BasicCollectionPersister confRoomMeta = (BasicCollectionPersister) sf.getCollectionMetadata( Company.class.getName() + ".conferenceRoomExtensions" );
|
||||
assertEquals( "company_id", confRoomMeta.getKeyColumnNames()[0] );
|
||||
assertEquals( "phone_extension", confRoomMeta.getElementColumnNames()[0] );
|
||||
assertEquals( "room_number", confRoomMeta.getIndexColumnNames()[0] );
|
||||
assertEquals( "phone_extension_lookup", confRoomMeta.getTableName() );
|
||||
tx.rollback();
|
||||
s.close();
|
||||
}
|
||||
|
||||
protected Class[] getAnnotatedClasses() {
|
||||
return new Class[] {
|
||||
CarModel.class,
|
||||
Manufacturer.class,
|
||||
Model.class,
|
||||
Light.class
|
||||
//Lighter.class xml only entuty
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String[] getXmlFiles() {
|
||||
return new String[] {
|
||||
"org/hibernate/test/annotations/xml/ejb3/orm.xml",
|
||||
"org/hibernate/test/annotations/xml/ejb3/orm2.xml",
|
||||
"org/hibernate/test/annotations/xml/ejb3/orm3.xml",
|
||||
"org/hibernate/test/annotations/xml/ejb3/orm4.xml"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,30 @@
|
|||
package org.hibernate.test.annotations.xml.ejb3;
|
||||
|
||||
public class VicePresident {
|
||||
int id;
|
||||
String name;
|
||||
}
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by
|
||||
* third-party contributors as indicated by either @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.xml.ejb3;
|
||||
|
||||
public class VicePresident {
|
||||
int id;
|
||||
String name;
|
||||
}
|
||||
|
|
|
@ -1,30 +1,54 @@
|
|||
<?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"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm/orm_2_0.xsd"
|
||||
version="2.0">
|
||||
<package>org.hibernate.test.annotations.xml.ejb3</package>
|
||||
<entity class="Company" access="FIELD" metadata-complete="true">
|
||||
<attributes>
|
||||
<id name="id"/>
|
||||
<one-to-many name="organization" target-entity="VicePresident">
|
||||
<map-key-class class="java.lang.String" />
|
||||
</one-to-many>
|
||||
<element-collection name="conferenceRoomExtensions" target-class="java.lang.String">
|
||||
<map-key-class class="java.lang.String" />
|
||||
<map-key-column name="room_number" />
|
||||
<column name="phone_extension"/>
|
||||
<collection-table name="phone_extension_lookup">
|
||||
<join-column name="company_id" referenced-column-name="id" />
|
||||
</collection-table>
|
||||
</element-collection>
|
||||
</attributes>
|
||||
</entity>
|
||||
<entity class="VicePresident" access="FIELD" metadata-complete="true">
|
||||
<attributes>
|
||||
<id name="id"/>
|
||||
<basic name="name"/>
|
||||
</attributes>
|
||||
</entity>
|
||||
</entity-mappings>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
~ Hibernate, Relational Persistence for Idiomatic Java
|
||||
~
|
||||
~ Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by
|
||||
~ third-party contributors as indicated by either @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
|
||||
-->
|
||||
|
||||
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm/orm_2_0.xsd"
|
||||
version="2.0">
|
||||
<package>org.hibernate.test.annotations.xml.ejb3</package>
|
||||
<entity class="Company" access="FIELD" metadata-complete="true">
|
||||
<attributes>
|
||||
<id name="id"/>
|
||||
<one-to-many name="organization" target-entity="VicePresident">
|
||||
<map-key-class class="java.lang.String"/>
|
||||
</one-to-many>
|
||||
<element-collection name="conferenceRoomExtensions" target-class="java.lang.String">
|
||||
<map-key-class class="java.lang.String"/>
|
||||
<map-key-column name="room_number"/>
|
||||
<column name="phone_extension"/>
|
||||
<collection-table name="phone_extension_lookup">
|
||||
<join-column name="company_id" referenced-column-name="id"/>
|
||||
</collection-table>
|
||||
</element-collection>
|
||||
</attributes>
|
||||
</entity>
|
||||
<entity class="VicePresident" access="FIELD" metadata-complete="true">
|
||||
<attributes>
|
||||
<id name="id"/>
|
||||
<basic name="name"/>
|
||||
</attributes>
|
||||
</entity>
|
||||
</entity-mappings>
|
||||
|
|
Loading…
Reference in New Issue