OPENJPA-855 Adding additional JPQL Index tests

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@916476 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Donald Woods 2010-02-25 22:08:44 +00:00
parent 9a4fe698c2
commit 06d3e4e65d
12 changed files with 747 additions and 0 deletions

View File

@ -0,0 +1,32 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.openjpa.persistence.jpql.entities;
public interface INameEntity {
public int getId();
public void setId(int id);
public String getName();
public void setName(String name);
public String toString();
}

View File

@ -0,0 +1,40 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.openjpa.persistence.jpql.entities;
import java.util.List;
public interface IOrderedEntity {
public int getId();
public void setId(int id);
public List<INameEntity> getEntities();
public void setEntities(List<INameEntity> entities);
public void addEntities(INameEntity entity);
public INameEntity removeEntities(int location);
public void insertEntities(int location, INameEntity entity);
public String toString();
}

View File

@ -0,0 +1,80 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.openjpa.persistence.jpql.entities;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OrderColumn;
@Entity
public class OrderedElementEntity implements java.io.Serializable {
@Id
private int id;
@ElementCollection
@OrderColumn
private List<String> listElements;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public List<String> getListElements() {
return listElements;
}
public void setListElements(List<String> elements) {
this.listElements = elements;
}
public void addListElements(String element) {
if( listElements == null) {
listElements = new ArrayList<String>();
}
listElements.add(element);
}
public String removeListElements(int location) {
String rtnVal = null;
if( listElements != null) {
rtnVal = listElements.remove(location);
}
return rtnVal;
}
public void insertListElements(int location, String name) {
if( listElements == null) {
listElements = new ArrayList<String>();
}
listElements.add(location, name);
}
public String toString() {
return "OrderedElementEntity[" + id + "]=" + listElements;
}
}

View File

@ -0,0 +1,81 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.openjpa.persistence.jpql.entities;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.OrderColumn;
@Entity
public class OrderedManyToManyEntity implements IOrderedEntity, java.io.Serializable {
@Id
private int id;
@ManyToMany
@OrderColumn
private List<INameEntity> om2mEntities;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public List<INameEntity> getEntities() {
return om2mEntities;
}
public void setEntities(List<INameEntity> entities) {
this.om2mEntities = entities;
}
public void addEntities(INameEntity entity) {
if( om2mEntities == null) {
om2mEntities = new ArrayList<INameEntity>();
}
om2mEntities.add(entity);
}
public INameEntity removeEntities(int location) {
INameEntity rtnVal = null;
if( om2mEntities != null) {
rtnVal = om2mEntities.remove(location);
}
return rtnVal;
}
public void insertEntities(int location, INameEntity entity) {
if( om2mEntities == null) {
om2mEntities = new ArrayList<INameEntity>();
}
om2mEntities.add(location, entity);
}
public String toString() {
return "OrderedManyToManyEntity[" + id + "]=" + om2mEntities;
}
}

View File

@ -0,0 +1,81 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.openjpa.persistence.jpql.entities;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OrderColumn;
@Entity
public class OrderedOneToManyEntity implements IOrderedEntity, java.io.Serializable {
@Id
private int id;
@OneToMany
@OrderColumn
private List<INameEntity> oo2mEntities;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public List<INameEntity> getEntities() {
return oo2mEntities;
}
public void setEntities(List<INameEntity> names) {
this.oo2mEntities = names;
}
public void addEntities(INameEntity name) {
if( oo2mEntities == null) {
oo2mEntities = new ArrayList<INameEntity>();
}
oo2mEntities.add(name);
}
public INameEntity removeEntities(int location) {
INameEntity rtnVal = null;
if( oo2mEntities != null) {
rtnVal = oo2mEntities.remove(location);
}
return rtnVal;
}
public void insertEntities(int location, INameEntity name) {
if( oo2mEntities == null) {
oo2mEntities = new ArrayList<INameEntity>();
}
oo2mEntities.add(location, name);
}
public String toString() {
return "OrderedOneToManyEntity[" + id + "]=" + oo2mEntities;
}
}

View File

@ -0,0 +1,60 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.openjpa.persistence.jpql.entities;
import javax.persistence.Entity;
import javax.persistence.Id;
@Entity
public class UnorderedNameEntity implements INameEntity, java.io.Serializable {
@Id
private int id;
private String name;
public UnorderedNameEntity() {
}
public UnorderedNameEntity(String name) {
this.id = name.charAt(0) - 'A' + 1;
this.name = name;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String toString() {
return "UnorderedNameEntity[" + id + "]=" + name;
}
}

View File

@ -0,0 +1,71 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.openjpa.persistence.jpql.entities;
import java.util.ArrayList;
import java.util.List;
public class XMLOrderedElementEntity implements java.io.Serializable {
private int id;
private List<String> listElements;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public List<String> getListElements() {
return listElements;
}
public void setListElements(List<String> elements) {
this.listElements = elements;
}
public void addListElements(String element) {
if( listElements == null) {
listElements = new ArrayList<String>();
}
listElements.add(element);
}
public String removeListElements(int location) {
String rtnVal = null;
if( listElements != null) {
rtnVal = listElements.remove(location);
}
return rtnVal;
}
public void insertListElements(int location, String name) {
if( listElements == null) {
listElements = new ArrayList<String>();
}
listElements.add(location, name);
}
public String toString() {
return "XMLOrderedElementEntity[" + id + "]=" + listElements;
}
}

View File

@ -0,0 +1,72 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.openjpa.persistence.jpql.entities;
import java.util.ArrayList;
import java.util.List;
public class XMLOrderedManyToManyEntity implements IOrderedEntity, java.io.Serializable {
private int id;
private List<INameEntity> xom2mEntities;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public List<INameEntity> getEntities() {
return xom2mEntities;
}
public void setEntities(List<INameEntity> entities) {
this.xom2mEntities = entities;
}
public void addEntities(INameEntity entity) {
if( xom2mEntities == null) {
xom2mEntities = new ArrayList<INameEntity>();
}
xom2mEntities.add(entity);
}
public INameEntity removeEntities(int location) {
INameEntity rtnVal = null;
if( xom2mEntities != null) {
rtnVal = xom2mEntities.remove(location);
}
return rtnVal;
}
public void insertEntities(int location, INameEntity entity) {
if( xom2mEntities == null) {
xom2mEntities = new ArrayList<INameEntity>();
}
xom2mEntities.add(location, entity);
}
public String toString() {
return "XMLOrderedManyToManyEntity[" + id + "]=" + xom2mEntities;
}
}

View File

@ -0,0 +1,72 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.openjpa.persistence.jpql.entities;
import java.util.ArrayList;
import java.util.List;
public class XMLOrderedOneToManyEntity implements IOrderedEntity, java.io.Serializable {
private int id;
private List<INameEntity> xoo2mEntities;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public List<INameEntity> getEntities() {
return xoo2mEntities;
}
public void setEntities(List<INameEntity> entities) {
this.xoo2mEntities = entities;
}
public void addEntities(INameEntity entity) {
if( xoo2mEntities == null) {
xoo2mEntities = new ArrayList<INameEntity>();
}
xoo2mEntities.add(entity);
}
public INameEntity removeEntities(int location) {
INameEntity rtnVal = null;
if( xoo2mEntities != null) {
rtnVal = xoo2mEntities.remove(location);
}
return rtnVal;
}
public void insertEntities(int location, INameEntity entity) {
if( xoo2mEntities == null) {
xoo2mEntities = new ArrayList<INameEntity>();
}
xoo2mEntities.add(location, entity);
}
public String toString() {
return "XMLOrderedOneToManyEntity[" + id + "]=" + xoo2mEntities;
}
}

View File

@ -0,0 +1,55 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.openjpa.persistence.jpql.entities;
public class XMLUnorderedNameEntity implements INameEntity, java.io.Serializable {
private int id;
private String name;
public XMLUnorderedNameEntity() {
}
public XMLUnorderedNameEntity(String name) {
this.id = name.charAt(0) - 'A' + 1;
this.name = name;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String toString() {
return "XMLUnorderedNameEntity[" + id + "]=" + name;
}
}

View File

@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_2_0.xsd" version="2.0">
<entity class="org.apache.openjpa.persistence.jpql.entities.XMLOrderedManyToManyEntity">
<attributes>
<id name="id" />
<many-to-many name="xom2mEntities">
<order-column/>
</many-to-many>
</attributes>
</entity>
<entity class="org.apache.openjpa.persistence.jpql.entities.XMLOrderedOneToManyEntity">
<attributes>
<id name="id" />
<one-to-many name="xoo2mEntities">
<order-column/>
</one-to-many>
</attributes>
</entity>
<entity class="org.apache.openjpa.persistence.jpql.entities.XMLOrderedElementEntity">
<attributes>
<id name="id" />
<element-collection name="listElements">
<order-column />
</element-collection>
</attributes>
</entity>
<entity class="org.apache.openjpa.persistence.jpql.entities.XMLUnorderedNameEntity">
<attributes>
<id name="id" />
<basic name="name" />
</attributes>
</entity>
</entity-mappings>

View File

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<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="JPQLIndex" transaction-type="RESOURCE_LOCAL">
<description>PU for JPQL Index testing</description>
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
<mapping-file>org/apache/openjpa/persistence/jpql/expressions/orm.xml</mapping-file>
<class>org.apache.openjpa.persistence.jpql.entities.OrderedElementEntity</class>
<class>org.apache.openjpa.persistence.jpql.entities.XMLOrderedElementEntity</class>
<class>org.apache.openjpa.persistence.jpql.entities.OrderedManyToManyEntity</class>
<class>org.apache.openjpa.persistence.jpql.entities.XMLOrderedManyToManyEntity</class>
<class>org.apache.openjpa.persistence.jpql.entities.OrderedOneToManyEntity</class>
<class>org.apache.openjpa.persistence.jpql.entities.XMLOrderedOneToManyEntity</class>
<class>org.apache.openjpa.persistence.jpql.entities.UnorderedNameEntity</class>
<class>org.apache.openjpa.persistence.jpql.entities.XMLUnorderedNameEntity</class>
<properties>
<property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema" />
<!-- property name="openjpa.Log" value="SQL=TRACE"/ -->
<property name="openjpa.RuntimeUnenhancedClasses" value="unsupported"/>
</properties>
</persistence-unit>
</persistence>