diff --git a/batoo-community-tests/src/test/java/org/batoo/jpa/community/test/i216/Category.java b/batoo-community-tests/src/test/java/org/batoo/jpa/community/test/i216/Category.java new file mode 100644 index 00000000..f454686e --- /dev/null +++ b/batoo-community-tests/src/test/java/org/batoo/jpa/community/test/i216/Category.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2012-2013, Batu Alp Ceylan + * + * 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.batoo.jpa.community.test.i216; + +import java.util.ArrayList; +import java.util.List; + +import javax.persistence.Basic; +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.ManyToMany; + +@Entity +public class Category { + + @Id + @Basic(optional = false) + @GeneratedValue + @Column(name = "ID") + private Integer id; + + + @ManyToMany(targetEntity = Item.class, fetch = FetchType.LAZY, cascade = {CascadeType.REFRESH}) + @JoinTable(name = "ITEM_CATEGORY", + joinColumns = {@JoinColumn(name = "CATEGORY_ID", referencedColumnName = "ID")}, + inverseJoinColumns = {@JoinColumn(name = "ITEM_ID", referencedColumnName = "ID")}) + private List items = new ArrayList(); + +} diff --git a/batoo-community-tests/src/test/java/org/batoo/jpa/community/test/i216/Item.java b/batoo-community-tests/src/test/java/org/batoo/jpa/community/test/i216/Item.java new file mode 100644 index 00000000..435758c8 --- /dev/null +++ b/batoo-community-tests/src/test/java/org/batoo/jpa/community/test/i216/Item.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2012-2013, Batu Alp Ceylan + * + * 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.batoo.jpa.community.test.i216; + +import java.util.ArrayList; +import java.util.List; + +import javax.persistence.Basic; +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.ManyToMany; + +@Entity +public class Item { + + @Id + @Basic(optional = false) + @GeneratedValue + @Column(name = "ID") + private Integer id; + + private String anyString; + + @ManyToMany(targetEntity = Category.class, fetch = FetchType.LAZY, cascade = { CascadeType.REFRESH}) + @JoinTable(name = "ITEM_CATEGORY", + joinColumns = {@JoinColumn(name = "ITEM_ID", referencedColumnName = "ID")}, + inverseJoinColumns = {@JoinColumn(name = "CATEGORY_ID", referencedColumnName = "ID")}) + private List categories = new ArrayList(); + + // get + set + hashCode + equals +} diff --git a/batoo-community-tests/src/test/java/org/batoo/jpa/community/test/i216/Test216.java b/batoo-community-tests/src/test/java/org/batoo/jpa/community/test/i216/Test216.java new file mode 100644 index 00000000..bc4768f6 --- /dev/null +++ b/batoo-community-tests/src/test/java/org/batoo/jpa/community/test/i216/Test216.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2012-2013, Batu Alp Ceylan + * + * 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.batoo.jpa.community.test.i216; + +import org.batoo.jpa.community.test.BaseCoreTest; +import org.junit.Test; + +/** + * Test for https://github.com/BatooOrg/BatooJPA/issues/216 + * + */ +@SuppressWarnings("javadoc") +public class Test216 extends BaseCoreTest { + + @Test + public void testIssue() { + } +} diff --git a/batoo-community-tests/src/test/java/org/batoo/jpa/community/test/i216/import.sql b/batoo-community-tests/src/test/java/org/batoo/jpa/community/test/i216/import.sql new file mode 100644 index 00000000..2703faba --- /dev/null +++ b/batoo-community-tests/src/test/java/org/batoo/jpa/community/test/i216/import.sql @@ -0,0 +1,4 @@ +CREATE TABLE ITEM (ID INT NOT NULL, name VARCHAR(128), PRIMARY KEY ( ID ) ); +CREATE TABLE CATEGORY (ID INT NOT NULL, name VARCHAR(128), PRIMARY KEY ( ID ) ); +CREATE TABLE ITEM_CATEGORY (ITEM_ID INT NOT NULL, CATEGORY_ID INT NOT NULL, PRIMARY KEY ( ITEM_ID, CATEGORY_ID ) ); + diff --git a/batoo-community-tests/src/test/java/org/batoo/jpa/community/test/i216/persistence.xml b/batoo-community-tests/src/test/java/org/batoo/jpa/community/test/i216/persistence.xml new file mode 100644 index 00000000..7a1619e0 --- /dev/null +++ b/batoo-community-tests/src/test/java/org/batoo/jpa/community/test/i216/persistence.xml @@ -0,0 +1,41 @@ + + + + + + org.batoo.jpa.core.BatooPersistenceProvider + + org.batoo.jpa.community.test.i216.Category + org.batoo.jpa.community.test.i216.Item + true + + + + + + + + + + +