HHH-9633 - Add tests that explicitly test the "main" NamingStrategy impls
This commit is contained in:
parent
ef3f00ad9f
commit
fa157745b2
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2015, 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.namingstrategy.complete;
|
||||
|
||||
import javax.persistence.Basic;
|
||||
import javax.persistence.Embeddable;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@Embeddable
|
||||
public class Address {
|
||||
public String line1;
|
||||
public String line2;
|
||||
public ZipCode zipCode;
|
||||
|
||||
@Basic
|
||||
public String getLine1() {
|
||||
return line1;
|
||||
}
|
||||
|
||||
public void setLine1(String line1) {
|
||||
this.line1 = line1;
|
||||
}
|
||||
|
||||
@Basic
|
||||
public String getLine2() {
|
||||
return line2;
|
||||
}
|
||||
|
||||
public void setLine2(String line2) {
|
||||
this.line2 = line2;
|
||||
}
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn
|
||||
public ZipCode getZipCode() {
|
||||
return zipCode;
|
||||
}
|
||||
|
||||
public void setZipCode(ZipCode zipCode) {
|
||||
this.zipCode = zipCode;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2015, 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.namingstrategy.complete;
|
||||
|
||||
import org.hibernate.cfg.Configuration;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public abstract class BaseAnnotationBindingTests extends BaseNamingTests {
|
||||
@Override
|
||||
protected void applyFixtures(Configuration cfg) {
|
||||
cfg.addAnnotatedClass( Address.class )
|
||||
.addAnnotatedClass( Customer.class )
|
||||
.addAnnotatedClass( Order.class )
|
||||
.addAnnotatedClass( ZipCode.class );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2015, 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.namingstrategy.complete;
|
||||
|
||||
import org.hibernate.cfg.Configuration;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public abstract class BaseHbmBindingTests extends BaseNamingTests {
|
||||
@Override
|
||||
protected void applyFixtures(Configuration cfg) {
|
||||
cfg.addResource( "org/hibernate/test/namingstrategy/complete/Mappings.hbm.xml" );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,241 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2015, 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.namingstrategy.complete;
|
||||
|
||||
import org.hibernate.cfg.Configuration;
|
||||
import org.hibernate.dialect.H2Dialect;
|
||||
import org.hibernate.mapping.Collection;
|
||||
import org.hibernate.mapping.Column;
|
||||
import org.hibernate.mapping.Component;
|
||||
import org.hibernate.mapping.PersistentClass;
|
||||
import org.hibernate.mapping.Property;
|
||||
|
||||
import org.hibernate.testing.RequiresDialect;
|
||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hibernate.testing.junit4.ExtraAssertions.assertTyping;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@RequiresDialect( H2Dialect.class )
|
||||
public abstract class BaseNamingTests extends BaseUnitTestCase {
|
||||
@Test
|
||||
public void doTest() {
|
||||
final Configuration cfg = new Configuration();
|
||||
applyFixtures( cfg );
|
||||
cfg.buildMappings();
|
||||
|
||||
validateCustomer( cfg );
|
||||
validateOrder( cfg );
|
||||
validateZipCode( cfg );
|
||||
|
||||
validateCustomerRegisteredTrademarks( cfg );
|
||||
validateCustomerAddresses( cfg );
|
||||
validateCustomerOrders( cfg );
|
||||
}
|
||||
|
||||
protected abstract void applyFixtures(Configuration cfg);
|
||||
|
||||
protected void validateCustomer(Configuration cfg) {
|
||||
final PersistentClass customerBinding = cfg.getClassMapping( Customer.class.getName() );
|
||||
assertNotNull( customerBinding );
|
||||
|
||||
validateCustomerPrimaryTableName( customerBinding.getTable().getQuotedName() );
|
||||
|
||||
assertEquals( 1, customerBinding.getIdentifier().getColumnSpan() );
|
||||
validateCustomerPrimaryKeyColumn( (Column) customerBinding.getIdentifier().getColumnIterator().next() );
|
||||
|
||||
assertNotNull( customerBinding.getVersion() );
|
||||
assertEquals( 1, customerBinding.getVersion().getColumnSpan() );
|
||||
validateCustomerVersionColumn( (Column) customerBinding.getVersion().getColumnIterator().next() );
|
||||
|
||||
final Property nameBinding = customerBinding.getProperty( "name" );
|
||||
assertNotNull( nameBinding );
|
||||
assertEquals( 1, nameBinding.getColumnSpan() );
|
||||
validateCustomerNameColumn( (Column) nameBinding.getColumnIterator().next() );
|
||||
|
||||
final Property hqAddressBinding = customerBinding.getProperty( "hqAddress" );
|
||||
assertNotNull( hqAddressBinding );
|
||||
assertEquals( 3, hqAddressBinding.getColumnSpan() );
|
||||
validateCustomerHqAddressComponent( assertTyping( Component.class, hqAddressBinding.getValue() ) );
|
||||
}
|
||||
|
||||
protected abstract void validateCustomerPrimaryTableName(String name);
|
||||
|
||||
protected abstract void validateCustomerPrimaryKeyColumn(Column column);
|
||||
|
||||
protected abstract void validateCustomerVersionColumn(Column column);
|
||||
|
||||
protected abstract void validateCustomerNameColumn(Column column);
|
||||
|
||||
protected abstract void validateCustomerHqAddressComponent(Component component);
|
||||
|
||||
|
||||
protected void validateOrder(Configuration cfg) {
|
||||
final PersistentClass orderBinding = cfg.getClassMapping( Order.class.getName() );
|
||||
assertNotNull( orderBinding );
|
||||
|
||||
validateOrderPrimaryTableName( orderBinding.getTable().getQuotedName() );
|
||||
|
||||
assertEquals( 1, orderBinding.getIdentifier().getColumnSpan() );
|
||||
validateOrderPrimaryKeyColumn( (Column) orderBinding.getIdentifier().getColumnIterator().next() );
|
||||
|
||||
final Property referenceCodeBinding = orderBinding.getProperty( "referenceCode" );
|
||||
assertNotNull( referenceCodeBinding );
|
||||
assertEquals( 1, referenceCodeBinding.getColumnSpan() );
|
||||
validateOrderReferenceCodeColumn( (Column) referenceCodeBinding.getColumnIterator().next() );
|
||||
|
||||
final Property placedBinding = orderBinding.getProperty( "placed" );
|
||||
assertNotNull( placedBinding );
|
||||
assertEquals( 1, placedBinding.getColumnSpan() );
|
||||
validateOrderPlacedColumn( (Column) placedBinding.getColumnIterator().next() );
|
||||
|
||||
final Property fulfilledBinding = orderBinding.getProperty( "fulfilled" );
|
||||
assertNotNull( fulfilledBinding );
|
||||
assertEquals( 1, fulfilledBinding.getColumnSpan() );
|
||||
validateOrderFulfilledColumn( (Column) fulfilledBinding.getColumnIterator().next() );
|
||||
|
||||
final Property customerBinding = orderBinding.getProperty( "customer" );
|
||||
assertNotNull( customerBinding );
|
||||
assertEquals( 1, customerBinding.getColumnSpan() );
|
||||
validateOrderCustomerColumn( (Column) customerBinding.getColumnIterator().next() );
|
||||
}
|
||||
|
||||
protected abstract void validateOrderPrimaryTableName(String name);
|
||||
|
||||
protected abstract void validateOrderPrimaryKeyColumn(Column column);
|
||||
|
||||
protected abstract void validateOrderReferenceCodeColumn(Column column);
|
||||
|
||||
protected abstract void validateOrderFulfilledColumn(Column column);
|
||||
|
||||
protected abstract void validateOrderPlacedColumn(Column column);
|
||||
|
||||
protected abstract void validateOrderCustomerColumn(Column column);
|
||||
|
||||
|
||||
|
||||
protected void validateZipCode(Configuration cfg) {
|
||||
final PersistentClass zipCodeBinding = cfg.getClassMapping( ZipCode.class.getName() );
|
||||
assertNotNull( zipCodeBinding );
|
||||
|
||||
validateZipCodePrimaryTableName( zipCodeBinding.getTable().getQuotedName() );
|
||||
|
||||
assertEquals( 1, zipCodeBinding.getIdentifier().getColumnSpan() );
|
||||
validateZipCodePrimaryKeyColumn( (Column) zipCodeBinding.getIdentifier().getColumnIterator().next() );
|
||||
|
||||
final Property codeBinding = zipCodeBinding.getProperty( "code" );
|
||||
assertNotNull( codeBinding );
|
||||
assertEquals( 1, codeBinding.getColumnSpan() );
|
||||
validateZipCodeCodeColumn( (Column) codeBinding.getColumnIterator().next() );
|
||||
|
||||
final Property cityBinding = zipCodeBinding.getProperty( "city" );
|
||||
assertNotNull( cityBinding );
|
||||
assertEquals( 1, cityBinding.getColumnSpan() );
|
||||
validateZipCodeCityColumn( (Column) cityBinding.getColumnIterator().next() );
|
||||
|
||||
final Property stateBinding = zipCodeBinding.getProperty( "state" );
|
||||
assertNotNull( stateBinding );
|
||||
assertEquals( 1, stateBinding.getColumnSpan() );
|
||||
validateZipCodeStateColumn( (Column) stateBinding.getColumnIterator().next() );
|
||||
}
|
||||
|
||||
protected abstract void validateZipCodePrimaryTableName(String name);
|
||||
|
||||
protected abstract void validateZipCodePrimaryKeyColumn(Column column);
|
||||
|
||||
protected abstract void validateZipCodeCodeColumn(Column column);
|
||||
|
||||
protected abstract void validateZipCodeCityColumn(Column column);
|
||||
|
||||
protected abstract void validateZipCodeStateColumn(Column column);
|
||||
|
||||
|
||||
protected void validateCustomerRegisteredTrademarks(Configuration cfg) {
|
||||
final Collection collectionBinding = cfg.getCollectionMapping( Customer.class.getName() + ".registeredTrademarks" );
|
||||
assertNotNull( collectionBinding );
|
||||
|
||||
validateCustomerRegisteredTrademarksTableName( collectionBinding.getCollectionTable().getName() );
|
||||
|
||||
assertEquals( 1, collectionBinding.getKey().getColumnSpan() );
|
||||
validateCustomerRegisteredTrademarksKeyColumn( (Column) collectionBinding.getKey().getColumnIterator().next() );
|
||||
|
||||
assertEquals( 1, collectionBinding.getElement().getColumnSpan() );
|
||||
validateCustomerRegisteredTrademarksElementColumn(
|
||||
(Column) collectionBinding.getElement()
|
||||
.getColumnIterator()
|
||||
.next()
|
||||
);
|
||||
}
|
||||
|
||||
protected abstract void validateCustomerRegisteredTrademarksTableName(String name);
|
||||
|
||||
protected abstract void validateCustomerRegisteredTrademarksKeyColumn(Column column);
|
||||
|
||||
protected abstract void validateCustomerRegisteredTrademarksElementColumn(Column column);
|
||||
|
||||
|
||||
protected void validateCustomerAddresses(Configuration cfg) {
|
||||
final Collection collectionBinding = cfg.getCollectionMapping( Customer.class.getName() + ".addresses" );
|
||||
assertNotNull( collectionBinding );
|
||||
|
||||
validateCustomerAddressesTableName( collectionBinding.getCollectionTable().getName() );
|
||||
|
||||
assertEquals( 1, collectionBinding.getKey().getColumnSpan() );
|
||||
validateCustomerAddressesKeyColumn( (Column) collectionBinding.getKey().getColumnIterator().next() );
|
||||
|
||||
assertEquals( 3, collectionBinding.getElement().getColumnSpan() );
|
||||
validateCustomerAddressesElementComponent( assertTyping( Component.class, collectionBinding.getElement() ) );
|
||||
}
|
||||
|
||||
protected abstract void validateCustomerAddressesTableName(String name);
|
||||
|
||||
protected abstract void validateCustomerAddressesKeyColumn(Column column);
|
||||
|
||||
protected abstract void validateCustomerAddressesElementComponent(Component component);
|
||||
|
||||
|
||||
protected void validateCustomerOrders(Configuration cfg) {
|
||||
final Collection collectionBinding = cfg.getCollectionMapping( Customer.class.getName() + ".orders" );
|
||||
assertNotNull( collectionBinding );
|
||||
|
||||
validateCustomerOrdersTableName( collectionBinding.getCollectionTable().getName() );
|
||||
|
||||
assertEquals( 1, collectionBinding.getKey().getColumnSpan() );
|
||||
validateCustomerOrdersKeyColumn( (Column) collectionBinding.getKey().getColumnIterator().next() );
|
||||
|
||||
assertEquals( 1, collectionBinding.getElement().getColumnSpan() );
|
||||
validateCustomerOrdersElementColumn( (Column) collectionBinding.getElement().getColumnIterator().next() );
|
||||
}
|
||||
|
||||
protected abstract void validateCustomerOrdersTableName(String name);
|
||||
|
||||
protected abstract void validateCustomerOrdersKeyColumn(Column column);
|
||||
|
||||
protected abstract void validateCustomerOrdersElementColumn(Column column);
|
||||
}
|
|
@ -0,0 +1,116 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2015, 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.namingstrategy.complete;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import javax.persistence.Basic;
|
||||
import javax.persistence.ElementCollection;
|
||||
import javax.persistence.Embedded;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Version;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@Entity
|
||||
public class Customer {
|
||||
private Integer id;
|
||||
private Integer version;
|
||||
private String name;
|
||||
private Set<String> registeredTrademarks;
|
||||
|
||||
private Address hqAddress;
|
||||
private Set<Address> addresses;
|
||||
|
||||
private List<Order> orders;
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Version
|
||||
public Integer getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(Integer version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
@Basic
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@ElementCollection
|
||||
public Set<String> getRegisteredTrademarks() {
|
||||
return registeredTrademarks;
|
||||
}
|
||||
|
||||
public void setRegisteredTrademarks(Set<String> registeredTrademarks) {
|
||||
this.registeredTrademarks = registeredTrademarks;
|
||||
}
|
||||
|
||||
@Embedded
|
||||
public Address getHqAddress() {
|
||||
return hqAddress;
|
||||
}
|
||||
|
||||
public void setHqAddress(Address hqAddress) {
|
||||
this.hqAddress = hqAddress;
|
||||
}
|
||||
|
||||
@ElementCollection
|
||||
@Embedded
|
||||
public Set<Address> getAddresses() {
|
||||
return addresses;
|
||||
}
|
||||
|
||||
public void setAddresses(Set<Address> addresses) {
|
||||
this.addresses = addresses;
|
||||
}
|
||||
|
||||
@OneToMany( mappedBy = "customer" )
|
||||
public List<Order> getOrders() {
|
||||
return orders;
|
||||
}
|
||||
|
||||
public void setOrders(List<Order> orders) {
|
||||
this.orders = orders;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,201 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2015, 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.namingstrategy.complete;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.hibernate.cfg.Configuration;
|
||||
import org.hibernate.cfg.EJB3NamingStrategy;
|
||||
import org.hibernate.mapping.Column;
|
||||
import org.hibernate.mapping.Component;
|
||||
import org.hibernate.mapping.Selectable;
|
||||
|
||||
import static org.hibernate.testing.junit4.ExtraAssertions.assertTyping;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class LegacyJpaNamingWithAnnotationBindingTests extends BaseAnnotationBindingTests {
|
||||
@Override
|
||||
protected void applyFixtures(Configuration cfg) {
|
||||
cfg.setNamingStrategy( EJB3NamingStrategy.INSTANCE );
|
||||
super.applyFixtures( cfg );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateCustomerPrimaryTableName(String name) {
|
||||
assertEquals( "Customer", name );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateCustomerPrimaryKeyColumn(Column column) {
|
||||
assertEquals( "id", column.getQuotedName() );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateCustomerVersionColumn(Column column) {
|
||||
assertEquals( "version", column.getQuotedName() );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateCustomerNameColumn(Column column) {
|
||||
assertEquals( "name", column.getQuotedName() );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateCustomerHqAddressComponent(Component component) {
|
||||
assertEquals( 3, component.getColumnSpan() );
|
||||
Iterator<Selectable> selectables = component.getColumnIterator();
|
||||
int pass = 1;
|
||||
while ( selectables.hasNext() ) {
|
||||
final Column column = assertTyping( Column.class, selectables.next() );
|
||||
if ( pass == 1 ) {
|
||||
assertEquals( "line1", column.getQuotedName() );
|
||||
}
|
||||
else if ( pass == 2 ) {
|
||||
assertEquals( "line2", column.getQuotedName() );
|
||||
}
|
||||
else if ( pass == 3 ) {
|
||||
assertEquals( "zipCode_id", column.getQuotedName() );
|
||||
}
|
||||
pass++;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateOrderPrimaryTableName(String name) {
|
||||
assertEquals( "Order", name );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateOrderPrimaryKeyColumn(Column column) {
|
||||
assertEquals( "id", column.getQuotedName() );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateOrderReferenceCodeColumn(Column column) {
|
||||
assertEquals( "referenceCode", column.getQuotedName() );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateOrderFulfilledColumn(Column column) {
|
||||
assertEquals( "fulfilled", column.getQuotedName() );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateOrderPlacedColumn(Column column) {
|
||||
assertEquals( "placed", column.getQuotedName() );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateOrderCustomerColumn(Column column) {
|
||||
assertEquals( "customer_id", column.getQuotedName() );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateZipCodePrimaryTableName(String name) {
|
||||
assertEquals( "ZipCode", name );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateZipCodePrimaryKeyColumn(Column column) {
|
||||
assertEquals( "id", column.getQuotedName() );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateZipCodeCodeColumn(Column column) {
|
||||
assertEquals( "code", column.getQuotedName() );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateZipCodeCityColumn(Column column) {
|
||||
assertEquals( "city", column.getQuotedName() );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateZipCodeStateColumn(Column column) {
|
||||
assertEquals( "state", column.getQuotedName() );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateCustomerRegisteredTrademarksTableName(String name) {
|
||||
assertEquals( "Customer_registeredTrademarks", name );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateCustomerRegisteredTrademarksKeyColumn(Column column) {
|
||||
assertEquals( "Customer_id", column.getQuotedName() );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateCustomerRegisteredTrademarksElementColumn(Column column) {
|
||||
assertEquals( "registeredTrademarks", column.getQuotedName() );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateCustomerAddressesTableName(String name) {
|
||||
assertEquals( "Customer_addresses", name );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateCustomerAddressesKeyColumn(Column column) {
|
||||
assertEquals( "Customer_id", column.getQuotedName() );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateCustomerAddressesElementComponent(Component component) {
|
||||
assertEquals( 3, component.getColumnSpan() );
|
||||
Iterator<Selectable> selectables = component.getColumnIterator();
|
||||
int pass = 1;
|
||||
while ( selectables.hasNext() ) {
|
||||
final Column column = assertTyping( Column.class, selectables.next() );
|
||||
if ( pass == 1 ) {
|
||||
assertEquals( "line1", column.getQuotedName() );
|
||||
}
|
||||
else if ( pass == 2 ) {
|
||||
assertEquals( "line2", column.getQuotedName() );
|
||||
}
|
||||
else if ( pass == 3 ) {
|
||||
assertEquals( "zipCode_id", column.getQuotedName() );
|
||||
}
|
||||
pass++;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateCustomerOrdersTableName(String name) {
|
||||
assertEquals( "Order", name );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateCustomerOrdersKeyColumn(Column column) {
|
||||
assertEquals( "customer_id", column.getQuotedName() );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateCustomerOrdersElementColumn(Column column) {
|
||||
assertEquals( "id", column.getQuotedName() );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,204 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2015, 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.namingstrategy.complete;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.hibernate.cfg.Configuration;
|
||||
import org.hibernate.cfg.EJB3NamingStrategy;
|
||||
import org.hibernate.mapping.Column;
|
||||
import org.hibernate.mapping.Component;
|
||||
import org.hibernate.mapping.Selectable;
|
||||
|
||||
import static org.hibernate.testing.junit4.ExtraAssertions.assertTyping;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* The default naming strategy is actually always EJB3NamingStrategy historically,
|
||||
* even when binding hbm documents. So test that combo.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class LegacyJpaNamingWithHbmBindingTests extends BaseHbmBindingTests {
|
||||
@Override
|
||||
protected void applyFixtures(Configuration cfg) {
|
||||
cfg.setNamingStrategy( EJB3NamingStrategy.INSTANCE );
|
||||
super.applyFixtures( cfg );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateCustomerPrimaryTableName(String name) {
|
||||
assertEquals( "Customer", name );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateCustomerPrimaryKeyColumn(Column column) {
|
||||
assertEquals( "id", column.getQuotedName() );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateCustomerVersionColumn(Column column) {
|
||||
assertEquals( "version", column.getQuotedName() );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateCustomerNameColumn(Column column) {
|
||||
assertEquals( "name", column.getQuotedName() );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateCustomerHqAddressComponent(Component component) {
|
||||
assertEquals( 3, component.getColumnSpan() );
|
||||
Iterator<Selectable> selectables = component.getColumnIterator();
|
||||
int pass = 1;
|
||||
while ( selectables.hasNext() ) {
|
||||
final Column column = assertTyping( Column.class, selectables.next() );
|
||||
if ( pass == 1 ) {
|
||||
assertEquals( "line1", column.getQuotedName() );
|
||||
}
|
||||
else if ( pass == 2 ) {
|
||||
assertEquals( "line2", column.getQuotedName() );
|
||||
}
|
||||
else if ( pass == 3 ) {
|
||||
assertEquals( "zipCode", column.getQuotedName() );
|
||||
}
|
||||
pass++;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateOrderPrimaryTableName(String name) {
|
||||
assertEquals( "Order", name );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateOrderPrimaryKeyColumn(Column column) {
|
||||
assertEquals( "id", column.getQuotedName() );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateOrderReferenceCodeColumn(Column column) {
|
||||
assertEquals( "referenceCode", column.getQuotedName() );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateOrderFulfilledColumn(Column column) {
|
||||
assertEquals( "fulfilled", column.getQuotedName() );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateOrderPlacedColumn(Column column) {
|
||||
assertEquals( "placed", column.getQuotedName() );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateOrderCustomerColumn(Column column) {
|
||||
assertEquals( "customer", column.getQuotedName() );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateZipCodePrimaryTableName(String name) {
|
||||
assertEquals( "ZipCode", name );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateZipCodePrimaryKeyColumn(Column column) {
|
||||
assertEquals( "id", column.getQuotedName() );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateZipCodeCodeColumn(Column column) {
|
||||
assertEquals( "code", column.getQuotedName() );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateZipCodeCityColumn(Column column) {
|
||||
assertEquals( "city", column.getQuotedName() );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateZipCodeStateColumn(Column column) {
|
||||
assertEquals( "state", column.getQuotedName() );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateCustomerRegisteredTrademarksTableName(String name) {
|
||||
assertEquals( "Customer_registeredTrademarks", name );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateCustomerRegisteredTrademarksKeyColumn(Column column) {
|
||||
assertEquals( "id", column.getQuotedName() );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateCustomerRegisteredTrademarksElementColumn(Column column) {
|
||||
assertEquals( "elt", column.getQuotedName() );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateCustomerAddressesTableName(String name) {
|
||||
assertEquals( "Customer_addresses", name );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateCustomerAddressesKeyColumn(Column column) {
|
||||
assertEquals( "id", column.getQuotedName() );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateCustomerAddressesElementComponent(Component component) {
|
||||
assertEquals( 3, component.getColumnSpan() );
|
||||
Iterator<Selectable> selectables = component.getColumnIterator();
|
||||
int pass = 1;
|
||||
while ( selectables.hasNext() ) {
|
||||
final Column column = assertTyping( Column.class, selectables.next() );
|
||||
if ( pass == 1 ) {
|
||||
assertEquals( "line1", column.getQuotedName() );
|
||||
}
|
||||
else if ( pass == 2 ) {
|
||||
assertEquals( "line2", column.getQuotedName() );
|
||||
}
|
||||
else if ( pass == 3 ) {
|
||||
assertEquals( "zipCode", column.getQuotedName() );
|
||||
}
|
||||
pass++;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateCustomerOrdersTableName(String name) {
|
||||
assertEquals( "Order", name );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateCustomerOrdersKeyColumn(Column column) {
|
||||
assertEquals( "id", column.getQuotedName() );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void validateCustomerOrdersElementColumn(Column column) {
|
||||
assertEquals( "id", column.getQuotedName() );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
<?xml version="1.0"?>
|
||||
<!--
|
||||
~ Hibernate, Relational Persistence for Idiomatic Java
|
||||
~
|
||||
~ Copyright (c) 2015, 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
|
||||
-->
|
||||
<!DOCTYPE hibernate-mapping PUBLIC
|
||||
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
|
||||
|
||||
<hibernate-mapping package="org.hibernate.test.namingstrategy.complete">
|
||||
|
||||
<class name="Customer">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<version name="version"/>
|
||||
<property name="name"/>
|
||||
<component name="hqAddress">
|
||||
<property name="line1"/>
|
||||
<property name="line2"/>
|
||||
<many-to-one name="zipCode" class="ZipCode"/>
|
||||
</component>
|
||||
|
||||
<set name="registeredTrademarks">
|
||||
<key/>
|
||||
<element/>
|
||||
</set>
|
||||
|
||||
<set name="addresses">
|
||||
<key/>
|
||||
<composite-element class="Address">
|
||||
<property name="line1"/>
|
||||
<property name="line2"/>
|
||||
<many-to-one name="zipCode" class="ZipCode"/>
|
||||
</composite-element>
|
||||
</set>
|
||||
|
||||
<set name="orders" inverse="true">
|
||||
<key/>
|
||||
<one-to-many class="Order"/>
|
||||
</set>
|
||||
</class>
|
||||
|
||||
<class name="Order">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<natural-id>
|
||||
<property name="referenceCode"/>
|
||||
</natural-id>
|
||||
<property name="placed" type="timestamp"/>
|
||||
<property name="fulfilled" type="timestamp"/>
|
||||
<many-to-one name="customer" class="Customer"/>
|
||||
</class>
|
||||
|
||||
<class name="ZipCode">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<natural-id>
|
||||
<property name="code"/>
|
||||
</natural-id>
|
||||
<property name="city"/>
|
||||
<property name="state" type="EnumeratedType"/>
|
||||
</class>
|
||||
</hibernate-mapping>
|
|
@ -0,0 +1,98 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2015, 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.namingstrategy.complete;
|
||||
|
||||
import java.util.Date;
|
||||
import javax.persistence.Basic;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
import org.hibernate.annotations.NaturalId;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@Entity
|
||||
public class Order {
|
||||
private Integer id;
|
||||
private String referenceCode;
|
||||
|
||||
private Date placed;
|
||||
private Date fulfilled;
|
||||
|
||||
private Customer customer;
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@NaturalId
|
||||
public String getReferenceCode() {
|
||||
return referenceCode;
|
||||
}
|
||||
|
||||
public void setReferenceCode(String referenceCode) {
|
||||
this.referenceCode = referenceCode;
|
||||
}
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP )
|
||||
public Date getPlaced() {
|
||||
return placed;
|
||||
}
|
||||
|
||||
public void setPlaced(Date placed) {
|
||||
this.placed = placed;
|
||||
}
|
||||
|
||||
@Temporal(TemporalType.TIMESTAMP )
|
||||
public Date getFulfilled() {
|
||||
return fulfilled;
|
||||
}
|
||||
|
||||
public void setFulfilled(Date fulfilled) {
|
||||
this.fulfilled = fulfilled;
|
||||
}
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn
|
||||
public Customer getCustomer() {
|
||||
return customer;
|
||||
}
|
||||
|
||||
public void setCustomer(Customer customer) {
|
||||
this.customer = customer;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2015, 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.namingstrategy.complete;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public enum State {
|
||||
ALABAMA( "AL", "Alabama" ),
|
||||
ALASKA( "AK", "Alaska" ),
|
||||
ARIZONA( "AZ", "Arizona" ),
|
||||
ARKANSAS( "AR", "Arkansas" )
|
||||
// etc
|
||||
;
|
||||
|
||||
private final String isoCode;
|
||||
private final String text;
|
||||
|
||||
private State(String isoCode, String text) {
|
||||
this.isoCode = isoCode;
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2015, 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.namingstrategy.complete;
|
||||
|
||||
import javax.persistence.Basic;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
|
||||
import org.hibernate.annotations.NaturalId;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@Entity
|
||||
public class ZipCode {
|
||||
private Integer id;
|
||||
private String code;
|
||||
|
||||
private String city;
|
||||
private State state;
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@NaturalId
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
@Basic
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
@Enumerated
|
||||
public State getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(State state) {
|
||||
this.state = state;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
/**
|
||||
* Defines tests of the "main" NamingStrategies, mainly so that we can leverage this
|
||||
* in the 5.0 work to assert that the same names are produced.
|
||||
*/
|
||||
package org.hibernate.test.namingstrategy.complete;
|
Loading…
Reference in New Issue