-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e02e881
commit 1f87708
Showing
5 changed files
with
186 additions
and
0 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
batoo-community-tests/src/test/java/org/batoo/jpa/community/test/i216/Category.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Item> items = new ArrayList<Item>(); | ||
|
||
} |
54 changes: 54 additions & 0 deletions
54
batoo-community-tests/src/test/java/org/batoo/jpa/community/test/i216/Item.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Category> categories = new ArrayList<Category>(); | ||
|
||
// get + set + hashCode + equals | ||
} |
35 changes: 35 additions & 0 deletions
35
batoo-community-tests/src/test/java/org/batoo/jpa/community/test/i216/Test216.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() { | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
batoo-community-tests/src/test/java/org/batoo/jpa/community/test/i216/import.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ) ); | ||
|
41 changes: 41 additions & 0 deletions
41
batoo-community-tests/src/test/java/org/batoo/jpa/community/test/i216/persistence.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<!-- | ||
~ 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 | ||
--> | ||
|
||
<persistence xmlns="http://java.sun.com/xml/ns/persistence" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" | ||
version="2.0"> | ||
|
||
<persistence-unit name="default"> | ||
<provider>org.batoo.jpa.core.BatooPersistenceProvider</provider> | ||
|
||
<class>org.batoo.jpa.community.test.i216.Category</class> | ||
<class>org.batoo.jpa.community.test.i216.Item</class> | ||
<exclude-unlisted-classes>true</exclude-unlisted-classes> | ||
<properties> | ||
<property name="org.batoo.jpa.ddl" value="DROP"/> | ||
<!--<property name="org.batoo.jdbc.import_sql" value="org/batoo/jpa/community/test/i216/import.sql"/>--> | ||
<!--<property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.Driver40"/>--> | ||
<!--<property name="javax.persistence.jdbc.url" value="jdbc:derby:memory:test;create=true"/>--> | ||
<!--<property name="javax.persistence.jdbc.user" value="root"/>--> | ||
<!--<property name="javax.persistence.jdbc.password" value=""/>--> | ||
</properties> | ||
|
||
</persistence-unit> | ||
</persistence> |