Test: order of <mapping .../> affects caching configuration
This commit is contained in:
parent
c9d6d61adf
commit
1ec1254bab
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE hibernate-mapping PUBLIC
|
||||
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
|
||||
|
||||
<hibernate-mapping auto-import="false" default-access="field">
|
||||
<class name="org.hibernate.test.cfg.cache.BaseClass" table="BASECLASS"
|
||||
discriminator-value="B">
|
||||
<id name="id" column="ID_">
|
||||
<generator class="native" />
|
||||
</id>
|
||||
<discriminator type="char" />
|
||||
|
||||
<property name="value" column="VALUE_" />
|
||||
</class>
|
||||
</hibernate-mapping>
|
|
@ -0,0 +1,23 @@
|
|||
package org.hibernate.test.cfg.cache;
|
||||
|
||||
public class BaseClass {
|
||||
Long id;
|
||||
String value;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
}
|
44
hibernate-core/src/test/java/org/hibernate/test/cfg/cache/CacheConfigurationTest.java
vendored
Normal file
44
hibernate-core/src/test/java/org/hibernate/test/cfg/cache/CacheConfigurationTest.java
vendored
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2009-2011, 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.cfg.cache;
|
||||
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Tests using of cacheable configuration files.
|
||||
*
|
||||
* @author Tair Sabirgaliev
|
||||
*/
|
||||
public class CacheConfigurationTest extends BaseUnitTestCase {
|
||||
public static final String CFG_XML = "org/hibernate/test/cfg/cache/hibernate.cfg.xml";
|
||||
|
||||
@Test
|
||||
public void testCacheConfiguration() throws Exception {
|
||||
Configuration cfg = new Configuration().configure(CFG_XML);
|
||||
SessionFactory sessionFactory = cfg.buildSessionFactory();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<!DOCTYPE hibernate-mapping PUBLIC
|
||||
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
|
||||
|
||||
<hibernate-mapping auto-import="false" default-access="field">
|
||||
|
||||
<class name="org.hibernate.test.cfg.cache.Item" table="ITEM">
|
||||
<id name="id" column="ID_">
|
||||
<generator class="native" />
|
||||
</id>
|
||||
|
||||
<property name="name" column="NAME_" />
|
||||
</class>
|
||||
|
||||
</hibernate-mapping>
|
|
@ -0,0 +1,24 @@
|
|||
package org.hibernate.test.cfg.cache;
|
||||
|
||||
public class Item {
|
||||
Long id;
|
||||
|
||||
String name;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE hibernate-mapping PUBLIC
|
||||
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
|
||||
|
||||
<hibernate-mapping auto-import="false" default-access="field">
|
||||
<subclass name="org.hibernate.test.cfg.cache.SubClass"
|
||||
discriminator-value="S" extends="org.hibernate.test.cfg.cache.BaseClass">
|
||||
<set name="items" cascade="all">
|
||||
<key column="SUBCLASS_" foreign-key="FK_ITEM_SUBCLASS_" />
|
||||
<one-to-many class="org.hibernate.test.cfg.cache.Item" />
|
||||
</set>
|
||||
</subclass>
|
||||
</hibernate-mapping>
|
|
@ -0,0 +1,17 @@
|
|||
package org.hibernate.test.cfg.cache;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class SubClass extends BaseClass {
|
||||
Set<Item> items = new HashSet<Item>();
|
||||
|
||||
public Set<Item> getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
public void setItems(Set<Item> items) {
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
|
||||
<hibernate-configuration>
|
||||
<session-factory>
|
||||
<mapping resource="org/hibernate/test/cfg/cache/SubClass.hbm.xml"/>
|
||||
<mapping resource="org/hibernate/test/cfg/cache/BaseClass.hbm.xml"/>
|
||||
<mapping resource="org/hibernate/test/cfg/cache/Item.hbm.xml"/>
|
||||
|
||||
<class-cache class="org.hibernate.test.cfg.cache.BaseClass" usage="read-write"/>
|
||||
<collection-cache collection="org.hibernate.test.cfg.cache.SubClass.items" usage="read-write" />
|
||||
|
||||
</session-factory>
|
||||
</hibernate-configuration>
|
Loading…
Reference in New Issue