Skip to content

Commit

Permalink
tests for #216
Browse files Browse the repository at this point in the history
  • Loading branch information
asimarslan committed Nov 4, 2014
1 parent e02e881 commit 1f87708
Show file tree
Hide file tree
Showing 5 changed files with 186 additions and 0 deletions.
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>();

}
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
}
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() {
}
}
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 ) );

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>

0 comments on commit 1f87708

Please sign in to comment.