You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltaspike.apache.org by th...@apache.org on 2013/06/27 10:39:02 UTC
[02/11] DELTASPIKE-60 Data module initial import
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ae1a7147/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/spi/CdiQuerySpiTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/spi/CdiQuerySpiTest.java b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/spi/CdiQuerySpiTest.java
new file mode 100644
index 0000000..c679d20
--- /dev/null
+++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/spi/CdiQuerySpiTest.java
@@ -0,0 +1,76 @@
+/*
+ * 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.deltaspike.data.impl.spi;
+
+import static org.junit.Assert.assertNotNull;
+
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+import org.apache.deltaspike.data.test.TransactionalTestCase;
+import org.apache.deltaspike.data.test.domain.Simple;
+import org.apache.deltaspike.data.test.service.MyEntityRepository;
+import org.apache.deltaspike.data.test.service.MyEntityRepositoryDelegate;
+import org.apache.deltaspike.data.test.service.MySimpleRepository;
+import org.apache.deltaspike.data.test.util.TestDeployments;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.shrinkwrap.api.Archive;
+import org.junit.Test;
+
+public class CdiQuerySpiTest extends TransactionalTestCase
+{
+
+ @Deployment
+ public static Archive<?> deployment()
+ {
+ return TestDeployments.initDeployment()
+ .addClasses(MySimpleRepository.class,
+ MyEntityRepository.class,
+ MyEntityRepositoryDelegate.class)
+ .addPackage(Simple.class.getPackage());
+ }
+
+ @Produces
+ @PersistenceContext
+ private EntityManager entityManager;
+
+ @Inject
+ private MySimpleRepository repo;
+
+ @Test
+ public void should_call_delegate()
+ {
+ // given
+ Simple simple = new Simple("test_call_delegate");
+
+ // when
+ simple = repo.saveAndFlushAndRefresh(simple);
+
+ // then
+ assertNotNull(simple.getId());
+ }
+
+ @Override
+ protected EntityManager getEntityManager()
+ {
+ return entityManager;
+ }
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ae1a7147/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/util/EntityUtilsTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/util/EntityUtilsTest.java b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/util/EntityUtilsTest.java
new file mode 100755
index 0000000..cde1590
--- /dev/null
+++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/impl/util/EntityUtilsTest.java
@@ -0,0 +1,56 @@
+/*
+ * 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.deltaspike.data.impl.util;
+
+import java.io.Serializable;
+
+import org.apache.deltaspike.data.impl.util.EntityUtils;
+import org.apache.deltaspike.data.test.domain.Tee;
+import org.apache.deltaspike.data.test.domain.Tee2;
+import org.apache.deltaspike.data.test.domain.TeeId;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class EntityUtilsTest
+{
+
+ @Test
+ public void should_find_id_property_class()
+ {
+ // given
+
+ // when
+ Class<? extends Serializable> pkClass = EntityUtils.primaryKeyClass(Tee.class);
+
+ // then
+ Assert.assertEquals(TeeId.class, pkClass);
+ }
+
+ @Test
+ public void should_find_id_class()
+ {
+ // given
+
+ // when
+ Class<? extends Serializable> pkClass = EntityUtils.primaryKeyClass(Tee2.class);
+
+ // then
+ Assert.assertEquals(TeeId.class, pkClass);
+ }
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ae1a7147/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/TransactionalTestCase.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/TransactionalTestCase.java b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/TransactionalTestCase.java
new file mode 100644
index 0000000..0d90398
--- /dev/null
+++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/TransactionalTestCase.java
@@ -0,0 +1,53 @@
+/*
+ * 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.deltaspike.data.test;
+
+import javax.annotation.Resource;
+import javax.persistence.EntityManager;
+import javax.transaction.UserTransaction;
+
+import org.jboss.arquillian.junit.Arquillian;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.runner.RunWith;
+
+@RunWith(Arquillian.class)
+public abstract class TransactionalTestCase
+{
+
+ @Resource
+ protected UserTransaction ut;
+
+ @Before
+ public void startTransaction() throws Exception
+ {
+ ut.begin();
+ // Required by OpenJPA
+ getEntityManager().getMetamodel();
+ }
+
+ @After
+ public void rollbackTransaction() throws Exception
+ {
+ ut.rollback();
+ }
+
+ protected abstract EntityManager getEntityManager();
+
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ae1a7147/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/AuditedEntity.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/AuditedEntity.java b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/AuditedEntity.java
new file mode 100644
index 0000000..9d64eab
--- /dev/null
+++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/AuditedEntity.java
@@ -0,0 +1,129 @@
+/*
+ * 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.deltaspike.data.test.domain;
+
+import java.io.Serializable;
+import java.sql.Timestamp;
+import java.util.Calendar;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.ManyToOne;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+import org.apache.deltaspike.data.api.audit.CreatedOn;
+import org.apache.deltaspike.data.api.audit.ModifiedBy;
+import org.apache.deltaspike.data.api.audit.ModifiedOn;
+
+@Entity
+@SuppressWarnings("serial")
+public class AuditedEntity implements Serializable
+{
+
+ @Id
+ @GeneratedValue
+ private Long id;
+
+ @Temporal(TemporalType.TIMESTAMP)
+ @CreatedOn
+ private Calendar created;
+
+ private String name;
+
+ @ModifiedBy
+ private String changer;
+
+ @ModifiedBy
+ @ManyToOne(targetEntity = Principal.class, cascade = CascadeType.ALL, fetch = FetchType.EAGER)
+ private Principal principal;
+
+ @Temporal(TemporalType.TIME)
+ @ModifiedOn(onCreate = true)
+ private java.util.Date modified;
+
+ @Temporal(TemporalType.DATE)
+ @ModifiedOn
+ private Calendar gregorianModified;
+
+ @ModifiedOn
+ private Timestamp timestamp;
+
+ public AuditedEntity()
+ {
+ }
+
+ public Long getId()
+ {
+ return id;
+ }
+
+ public void setId(Long id)
+ {
+ this.id = id;
+ }
+
+ public Calendar getCreated()
+ {
+ return created;
+ }
+
+ public java.util.Date getModified()
+ {
+ return modified;
+ }
+
+ public Calendar getGregorianModified()
+ {
+ return gregorianModified;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public Timestamp getTimestamp()
+ {
+ return timestamp;
+ }
+
+ public String getChanger()
+ {
+ return changer;
+ }
+
+ public void setChanger(String changer)
+ {
+ this.changer = changer;
+ }
+
+ public Principal getPrincipal()
+ {
+ return principal;
+ }
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ae1a7147/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/EmbeddedSimple.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/EmbeddedSimple.java b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/EmbeddedSimple.java
new file mode 100644
index 0000000..081ffb0
--- /dev/null
+++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/EmbeddedSimple.java
@@ -0,0 +1,39 @@
+/*
+ * 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.deltaspike.data.test.domain;
+
+import javax.persistence.Embeddable;
+
+@Embeddable
+public class EmbeddedSimple
+{
+
+ private String embedd;
+
+ public String getEmbedd()
+ {
+ return embedd;
+ }
+
+ public void setEmbedd(String embedd)
+ {
+ this.embedd = embedd;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ae1a7147/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/Home.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/Home.java b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/Home.java
new file mode 100644
index 0000000..7d3fe2b
--- /dev/null
+++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/Home.java
@@ -0,0 +1,50 @@
+/*
+ * 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.deltaspike.data.test.domain;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+@Entity
+public class Home
+{
+
+ @Id
+ @GeneratedValue
+ private Long id;
+
+ private String name;
+
+ public Long getId()
+ {
+ return id;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ae1a7147/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/NamedEntity.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/NamedEntity.java b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/NamedEntity.java
new file mode 100644
index 0000000..77bb42e
--- /dev/null
+++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/NamedEntity.java
@@ -0,0 +1,59 @@
+/*
+ * 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.deltaspike.data.test.domain;
+
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.MappedSuperclass;
+
+@MappedSuperclass
+public class NamedEntity
+{
+
+ @Id
+ @GeneratedValue
+ private Long id;
+
+ private String name;
+
+ public NamedEntity()
+ {
+ }
+
+ public NamedEntity(String name)
+ {
+ this.name = name;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public Long getId()
+ {
+ return id;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ae1a7147/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/OneToMany.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/OneToMany.java b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/OneToMany.java
new file mode 100644
index 0000000..0f4c2e0
--- /dev/null
+++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/OneToMany.java
@@ -0,0 +1,37 @@
+/*
+ * 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.deltaspike.data.test.domain;
+
+import javax.persistence.Entity;
+
+@Entity
+public class OneToMany extends NamedEntity
+{
+
+ public OneToMany()
+ {
+ super();
+ }
+
+ public OneToMany(String name)
+ {
+ super(name);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ae1a7147/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/OneToOne.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/OneToOne.java b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/OneToOne.java
new file mode 100644
index 0000000..5718fe2
--- /dev/null
+++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/OneToOne.java
@@ -0,0 +1,36 @@
+/*
+ * 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.deltaspike.data.test.domain;
+
+import javax.persistence.Entity;
+
+@Entity
+public class OneToOne extends NamedEntity
+{
+
+ public OneToOne()
+ {
+ super();
+ }
+
+ public OneToOne(String name)
+ {
+ super(name);
+ }
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ae1a7147/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/Parent.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/Parent.java b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/Parent.java
new file mode 100644
index 0000000..00b7c2f
--- /dev/null
+++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/Parent.java
@@ -0,0 +1,90 @@
+/*
+ * 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.deltaspike.data.test.domain;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+
+@Entity
+public class Parent extends NamedEntity
+{
+
+ @javax.persistence.OneToOne(cascade = CascadeType.ALL)
+ private OneToOne one;
+
+ @javax.persistence.OneToMany(cascade = CascadeType.ALL, targetEntity = OneToMany.class)
+ private List<OneToMany> many = new LinkedList<OneToMany>();
+
+ private Long value = Long.valueOf(0);
+
+ public Parent()
+ {
+ super();
+ }
+
+ public Parent(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ public String toString()
+ {
+ return "Parent [value=" + value + ", getName()=" + getName() + ", getId()=" + getId() + "]";
+ }
+
+ public void add(OneToMany otm)
+ {
+ many.add(otm);
+ }
+
+ public OneToOne getOne()
+ {
+ return one;
+ }
+
+ public void setOne(OneToOne one)
+ {
+ this.one = one;
+ }
+
+ public List<OneToMany> getMany()
+ {
+ return many;
+ }
+
+ public void setMany(List<OneToMany> many)
+ {
+ this.many = many;
+ }
+
+ public Long getValue()
+ {
+ return value;
+ }
+
+ public void setValue(Long value)
+ {
+ this.value = value;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ae1a7147/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/Principal.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/Principal.java b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/Principal.java
new file mode 100644
index 0000000..efa772d
--- /dev/null
+++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/Principal.java
@@ -0,0 +1,73 @@
+/*
+ * 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.deltaspike.data.test.domain;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+@Entity
+public class Principal
+{
+
+ @Id
+ @GeneratedValue
+ private Long id;
+
+ private String name;
+
+ public Principal()
+ {
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder();
+ builder.append("Principal [id=").append(id)
+ .append(", name=").append(name).append("]");
+ return builder.toString();
+ }
+
+ public Principal(String name)
+ {
+ this.name = 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;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ae1a7147/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/Simple.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/Simple.java b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/Simple.java
new file mode 100755
index 0000000..6e5b3b1
--- /dev/null
+++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/Simple.java
@@ -0,0 +1,140 @@
+/*
+ * 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.deltaspike.data.test.domain;
+
+import java.util.Date;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+@Entity
+@NamedQueries({
+ @NamedQuery(name = Simple.BY_NAME_LIKE,
+ query = "select e from Simple e where e.name like ?1"),
+ @NamedQuery(name = Simple.BY_NAME_ENABLED,
+ query = "select s from Simple s where s.name = ?1 and s.enabled = ?2 order by s.id asc"),
+ @NamedQuery(name = Simple.BY_ID,
+ query = "select s from Simple s where s.id = :id and s.enabled = :enabled")
+})
+@Table(name = "SIMPLE_TABLE")
+public class Simple
+{
+
+ public static final String BY_NAME_LIKE = "simple.byNameLike";
+ public static final String BY_NAME_ENABLED = "simple.byNameAndEnabled";
+ public static final String BY_ID = "simple.byId";
+
+ @Id
+ @GeneratedValue
+ private Long id;
+
+ private String name;
+ private String camelCase;
+ private Boolean enabled = Boolean.TRUE;
+ private Integer counter = Integer.valueOf(0);
+ @Temporal(TemporalType.TIMESTAMP)
+ private Date temporal;
+ private EmbeddedSimple embedded;
+
+ public Simple()
+ {
+ }
+
+ public Simple(String name)
+ {
+ this.name = 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;
+ }
+
+ public Boolean getEnabled()
+ {
+ return enabled;
+ }
+
+ public void setEnabled(Boolean enabled)
+ {
+ this.enabled = enabled;
+ }
+
+ public Integer getCounter()
+ {
+ return counter;
+ }
+
+ public void setCounter(Integer counter)
+ {
+ this.counter = counter;
+ }
+
+ public String getCamelCase()
+ {
+ return camelCase;
+ }
+
+ public void setCamelCase(String camelCase)
+ {
+ this.camelCase = camelCase;
+ }
+
+ public Date getTemporal()
+ {
+ return temporal;
+ }
+
+ public void setTemporal(Date temporal)
+ {
+ this.temporal = temporal;
+ }
+
+ public EmbeddedSimple getEmbedded()
+ {
+ return embedded;
+ }
+
+ public void setEmbedded(EmbeddedSimple embedded)
+ {
+ this.embedded = embedded;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ae1a7147/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/Simple2.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/Simple2.java b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/Simple2.java
new file mode 100644
index 0000000..a9f155e
--- /dev/null
+++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/Simple2.java
@@ -0,0 +1,59 @@
+/*
+ * 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.deltaspike.data.test.domain;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+@Entity
+public class Simple2
+{
+
+ @Id
+ @GeneratedValue
+ private Long id;
+
+ private String name;
+
+ public Simple2()
+ {
+ }
+
+ public Simple2(String name)
+ {
+ this.name = name;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public Long getId()
+ {
+ return id;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ae1a7147/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/Simple3.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/Simple3.java b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/Simple3.java
new file mode 100644
index 0000000..8e9c420
--- /dev/null
+++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/Simple3.java
@@ -0,0 +1,50 @@
+/*
+ * 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.deltaspike.data.test.domain;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+
+@Entity
+public class Simple3
+{
+
+ @GeneratedValue
+ @Id
+ private long id;
+
+ private String name;
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public long getId()
+ {
+ return id;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ae1a7147/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/SimpleBuilder.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/SimpleBuilder.java b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/SimpleBuilder.java
new file mode 100644
index 0000000..c37fb41
--- /dev/null
+++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/SimpleBuilder.java
@@ -0,0 +1,53 @@
+/*
+ * 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.deltaspike.data.test.domain;
+
+import javax.persistence.EntityManager;
+
+public class SimpleBuilder
+{
+
+ private final EntityManager entityManager;
+
+ public SimpleBuilder(EntityManager entityManager)
+ {
+ this.entityManager = entityManager;
+ }
+
+ public Simple createSimple(String name, Integer counter)
+ {
+ Simple result = new Simple(name);
+ result.setCounter(counter);
+ return persistSimple(result);
+ }
+
+ public Simple createSimple(String name)
+ {
+ Simple result = new Simple(name);
+ return persistSimple(result);
+ }
+
+ public Simple persistSimple(Simple result)
+ {
+ entityManager.persist(result);
+ entityManager.flush();
+ return result;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ae1a7147/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/Tee.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/Tee.java b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/Tee.java
new file mode 100644
index 0000000..ecd2a30
--- /dev/null
+++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/Tee.java
@@ -0,0 +1,54 @@
+/*
+ * 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.deltaspike.data.test.domain;
+
+import java.io.Serializable;
+
+import javax.persistence.EmbeddedId;
+import javax.persistence.Entity;
+
+@Entity
+@SuppressWarnings("serial")
+public class Tee implements Serializable
+{
+
+ @EmbeddedId
+ private TeeId id;
+ private int distance;
+
+ public TeeId getId()
+ {
+ return id;
+ }
+
+ public void setId(TeeId id)
+ {
+ this.id = id;
+ }
+
+ public int getDistance()
+ {
+ return distance;
+ }
+
+ public void setDistance(int distance)
+ {
+ this.distance = distance;
+ }
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ae1a7147/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/Tee2.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/Tee2.java b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/Tee2.java
new file mode 100644
index 0000000..30f6de9
--- /dev/null
+++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/Tee2.java
@@ -0,0 +1,57 @@
+/*
+ * 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.deltaspike.data.test.domain;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.IdClass;
+
+@IdClass(TeeId.class)
+@Entity
+public class Tee2
+{
+ @Column(nullable = false)
+ @Id
+ private long teeSetId;
+
+ @Column(nullable = false)
+ @Id
+ private long holeId;
+
+ public long getTeeSetId()
+ {
+ return teeSetId;
+ }
+
+ public void setTeeSetId(long teeSetId)
+ {
+ this.teeSetId = teeSetId;
+ }
+
+ public long getHoleId()
+ {
+ return holeId;
+ }
+
+ public void setHoleId(long holeId)
+ {
+ this.holeId = holeId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ae1a7147/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/TeeId.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/TeeId.java b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/TeeId.java
new file mode 100644
index 0000000..453e389
--- /dev/null
+++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/TeeId.java
@@ -0,0 +1,103 @@
+/*
+ * 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.deltaspike.data.test.domain;
+
+import java.io.Serializable;
+
+import javax.persistence.Column;
+import javax.persistence.Embeddable;
+
+@Embeddable
+@SuppressWarnings("serial")
+public class TeeId implements Serializable
+{
+
+ @Column(nullable = false)
+ private long teeSetId;
+
+ @Column(nullable = false)
+ private long holeId;
+
+ public TeeId()
+ {
+ }
+
+ public TeeId(long teeSetId, long holeId)
+ {
+ this.teeSetId = teeSetId;
+ this.holeId = holeId;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + (int) (holeId ^ (holeId >>> 32));
+ result = prime * result + (int) (teeSetId ^ (teeSetId >>> 32));
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ {
+ return true;
+ }
+ if (obj == null)
+ {
+ return false;
+ }
+ if (getClass() != obj.getClass())
+ {
+ return false;
+ }
+ TeeId other = (TeeId) obj;
+ if (holeId != other.holeId)
+ {
+ return false;
+ }
+ if (teeSetId != other.teeSetId)
+ {
+ return false;
+ }
+ return true;
+ }
+
+ public long getTeeSetId()
+ {
+ return teeSetId;
+ }
+
+ public void setTeeSetId(long teeSetId)
+ {
+ this.teeSetId = teeSetId;
+ }
+
+ public long getHoleId()
+ {
+ return holeId;
+ }
+
+ public void setHoleId(long holeId)
+ {
+ this.holeId = holeId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ae1a7147/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/mapped/MappedId.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/mapped/MappedId.java b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/mapped/MappedId.java
new file mode 100644
index 0000000..6de64a4
--- /dev/null
+++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/mapped/MappedId.java
@@ -0,0 +1,36 @@
+/*
+ * 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.deltaspike.data.test.domain.mapped;
+
+public class MappedId
+{
+
+ private Long id;
+
+ public Long getId()
+ {
+ return id;
+ }
+
+ public void setId(Long id)
+ {
+ this.id = id;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ae1a7147/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/mapped/MappedOne.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/mapped/MappedOne.java b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/mapped/MappedOne.java
new file mode 100644
index 0000000..4a189a0
--- /dev/null
+++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/mapped/MappedOne.java
@@ -0,0 +1,56 @@
+/*
+ * 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.deltaspike.data.test.domain.mapped;
+
+public class MappedOne
+{
+
+ private Long id;
+ private String name;
+
+ public MappedOne()
+ {
+ }
+
+ public MappedOne(String name)
+ {
+ this.name = 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;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ae1a7147/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/mapped/MappedSuperclass.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/mapped/MappedSuperclass.java b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/mapped/MappedSuperclass.java
new file mode 100644
index 0000000..6bd3c7f
--- /dev/null
+++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/mapped/MappedSuperclass.java
@@ -0,0 +1,36 @@
+/*
+ * 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.deltaspike.data.test.domain.mapped;
+
+public class MappedSuperclass extends MappedId
+{
+
+ private Long counter;
+
+ public Long getCounter()
+ {
+ return counter;
+ }
+
+ public void setCounter(Long id)
+ {
+ this.counter = id;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ae1a7147/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/mapped/MappedThree.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/mapped/MappedThree.java b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/mapped/MappedThree.java
new file mode 100644
index 0000000..54b9120
--- /dev/null
+++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/mapped/MappedThree.java
@@ -0,0 +1,36 @@
+/*
+ * 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.deltaspike.data.test.domain.mapped;
+
+public class MappedThree extends MappedSuperclass
+{
+
+ private String name;
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ae1a7147/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/mapped/MappedTwo.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/mapped/MappedTwo.java b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/mapped/MappedTwo.java
new file mode 100644
index 0000000..2541675
--- /dev/null
+++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/domain/mapped/MappedTwo.java
@@ -0,0 +1,59 @@
+/*
+ * 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.deltaspike.data.test.domain.mapped;
+
+public class MappedTwo
+{
+
+ private Long teeSetId;
+ private Long holeId;
+
+ private String name;
+
+ public Long getTeeSetId()
+ {
+ return teeSetId;
+ }
+
+ public void setTeeSetId(Long teeSetId)
+ {
+ this.teeSetId = teeSetId;
+ }
+
+ public Long getHoleId()
+ {
+ return holeId;
+ }
+
+ public void setHoleId(Long holeId)
+ {
+ this.holeId = holeId;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ae1a7147/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/ExtendedRepositoryInterface.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/ExtendedRepositoryInterface.java b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/ExtendedRepositoryInterface.java
new file mode 100755
index 0000000..49ab7f4
--- /dev/null
+++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/ExtendedRepositoryInterface.java
@@ -0,0 +1,28 @@
+/*
+ * 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.deltaspike.data.test.service;
+
+import org.apache.deltaspike.data.api.EntityRepository;
+import org.apache.deltaspike.data.api.Repository;
+import org.apache.deltaspike.data.test.domain.Simple;
+
+@Repository
+public interface ExtendedRepositoryInterface extends EntityRepository<Simple, Long>
+{
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ae1a7147/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/HomeRepository.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/HomeRepository.java b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/HomeRepository.java
new file mode 100644
index 0000000..cc2aa51
--- /dev/null
+++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/HomeRepository.java
@@ -0,0 +1,30 @@
+/*
+ * 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.deltaspike.data.test.service;
+
+import org.apache.deltaspike.data.api.AbstractEntityRepository;
+import org.apache.deltaspike.data.api.QueryResult;
+import org.apache.deltaspike.data.test.domain.Home;
+
+public abstract class HomeRepository extends AbstractEntityRepository<Home, Long>
+{
+
+ public abstract QueryResult<Home> findByName(String name);
+
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ae1a7147/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/MappedOneRepository.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/MappedOneRepository.java b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/MappedOneRepository.java
new file mode 100644
index 0000000..1fcebd2
--- /dev/null
+++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/MappedOneRepository.java
@@ -0,0 +1,31 @@
+/*
+ * 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.deltaspike.data.test.service;
+
+import org.apache.deltaspike.data.api.AbstractEntityRepository;
+import org.apache.deltaspike.data.api.Repository;
+import org.apache.deltaspike.data.test.domain.mapped.MappedOne;
+
+@Repository
+public abstract class MappedOneRepository extends AbstractEntityRepository<MappedOne, Long>
+{
+
+ public abstract MappedOne findByName(String name);
+
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ae1a7147/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/MyEntityRepository.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/MyEntityRepository.java b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/MyEntityRepository.java
new file mode 100644
index 0000000..77ff8df
--- /dev/null
+++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/MyEntityRepository.java
@@ -0,0 +1,26 @@
+/*
+ * 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.deltaspike.data.test.service;
+
+public interface MyEntityRepository<E>
+{
+
+ E saveAndFlushAndRefresh(E entity);
+
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ae1a7147/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/MyEntityRepositoryDelegate.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/MyEntityRepositoryDelegate.java b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/MyEntityRepositoryDelegate.java
new file mode 100644
index 0000000..3977cb0
--- /dev/null
+++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/MyEntityRepositoryDelegate.java
@@ -0,0 +1,47 @@
+/*
+ * 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.deltaspike.data.test.service;
+
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+
+import org.apache.deltaspike.data.spi.DelegateQueryHandler;
+import org.apache.deltaspike.data.spi.QueryInvocationContext;
+
+public class MyEntityRepositoryDelegate<E> implements DelegateQueryHandler, MyEntityRepository<E>
+{
+
+ @Inject
+ private QueryInvocationContext context;
+
+ @Override
+ public E saveAndFlushAndRefresh(E entity)
+ {
+ entityManager().persist(entity);
+ entityManager().flush();
+ entityManager().refresh(entity);
+ return entity;
+ }
+
+ private EntityManager entityManager()
+ {
+ return context.getEntityManager();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ae1a7147/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/MySimpleRepository.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/MySimpleRepository.java b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/MySimpleRepository.java
new file mode 100644
index 0000000..9a03605
--- /dev/null
+++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/MySimpleRepository.java
@@ -0,0 +1,28 @@
+/*
+ * 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.deltaspike.data.test.service;
+
+import org.apache.deltaspike.data.api.EntityRepository;
+import org.apache.deltaspike.data.api.Repository;
+import org.apache.deltaspike.data.test.domain.Simple;
+
+@Repository
+public interface MySimpleRepository extends MyEntityRepository<Simple>, EntityRepository<Simple, Long>
+{
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ae1a7147/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/ParentRepository.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/ParentRepository.java b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/ParentRepository.java
new file mode 100644
index 0000000..3dd2e53
--- /dev/null
+++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/ParentRepository.java
@@ -0,0 +1,110 @@
+/*
+ * 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.deltaspike.data.test.service;
+
+import java.util.List;
+
+import javax.persistence.criteria.JoinType;
+
+import org.apache.deltaspike.data.api.AbstractEntityRepository;
+import org.apache.deltaspike.data.api.Repository;
+import org.apache.deltaspike.data.api.criteria.CriteriaSupport;
+import org.apache.deltaspike.data.test.domain.OneToMany;
+import org.apache.deltaspike.data.test.domain.OneToMany_;
+import org.apache.deltaspike.data.test.domain.OneToOne;
+import org.apache.deltaspike.data.test.domain.OneToOne_;
+import org.apache.deltaspike.data.test.domain.Parent;
+import org.apache.deltaspike.data.test.domain.Parent_;
+
+@Repository
+public abstract class ParentRepository extends AbstractEntityRepository<Parent, Long>
+ implements CriteriaSupport<Parent>
+{
+
+ public List<Parent> joinQuery(String name, String oneName, String manyName)
+ {
+ return criteria()
+ .eq(Parent_.name, name)
+ .join(Parent_.one,
+ where(OneToOne.class, JoinType.LEFT)
+ .eq(OneToOne_.name, oneName)
+ )
+ .join(Parent_.many,
+ where(OneToMany.class)
+ .eq(OneToMany_.name, manyName)
+ )
+ .createQuery()
+ .getResultList();
+ }
+
+ public List<Parent> nullAwareQuery(String name1, String name2, Long counter)
+ {
+ return criteria()
+ .eq(Parent_.name, name1)
+ .eq(Parent_.name, name2)
+ .eq(Parent_.value, counter)
+ .createQuery()
+ .getResultList();
+ }
+
+ public Parent fetchQuery(String name)
+ {
+ return criteria()
+ .eq(Parent_.name, name)
+ .fetch(Parent_.many)
+ .distinct()
+ .createQuery()
+ .getSingleResult();
+ }
+
+ public List<Parent> fetchByName(String name1, String name2, String name3)
+ {
+ return criteria()
+ .in(Parent_.name, name1, name2, name3)
+ .createQuery()
+ .getResultList();
+ }
+
+ @SuppressWarnings("unchecked")
+ public List<Parent> orQuery(String name1, String name2)
+ {
+ return criteria()
+ .or(
+ criteria()
+ .eq(Parent_.name, name2)
+ .between(Parent_.value, 50L, 100L),
+ criteria()
+ .eq(Parent_.name, name1)
+ .between(Parent_.value, 0L, 50L),
+ criteria()
+ .eq(Parent_.name, "does not exist!")
+ )
+ .createQuery()
+ .getResultList();
+ }
+
+ public List<Parent> orderedQuery()
+ {
+ return criteria()
+ .orderAsc(Parent_.name)
+ .createQuery()
+ .getResultList();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ae1a7147/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/RepositoryInterface.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/RepositoryInterface.java b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/RepositoryInterface.java
new file mode 100755
index 0000000..64e5dd0
--- /dev/null
+++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/RepositoryInterface.java
@@ -0,0 +1,28 @@
+/*
+ * 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.deltaspike.data.test.service;
+
+import org.apache.deltaspike.data.api.Repository;
+import org.apache.deltaspike.data.test.domain.Simple;
+
+@Repository(forEntity = Simple.class)
+public interface RepositoryInterface
+{
+
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ae1a7147/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/Simple2Repository.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/Simple2Repository.java b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/Simple2Repository.java
new file mode 100644
index 0000000..bf17c2f
--- /dev/null
+++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/Simple2Repository.java
@@ -0,0 +1,31 @@
+/*
+ * 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.deltaspike.data.test.service;
+
+import org.apache.deltaspike.data.api.EntityRepository;
+import org.apache.deltaspike.data.api.Repository;
+import org.apache.deltaspike.data.test.domain.Simple2;
+
+@Repository
+public interface Simple2Repository extends EntityRepository<Simple2, Long>
+{
+
+ Simple2 findByName(String name);
+
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ae1a7147/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/SimpleCriteriaRepository.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/SimpleCriteriaRepository.java b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/SimpleCriteriaRepository.java
new file mode 100644
index 0000000..3c5a159
--- /dev/null
+++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/SimpleCriteriaRepository.java
@@ -0,0 +1,75 @@
+/*
+ * 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.deltaspike.data.test.service;
+
+import java.util.List;
+
+import org.apache.deltaspike.data.api.AbstractEntityRepository;
+import org.apache.deltaspike.data.api.Repository;
+import org.apache.deltaspike.data.api.criteria.CriteriaSupport;
+import org.apache.deltaspike.data.test.domain.Simple;
+import org.apache.deltaspike.data.test.domain.Simple_;
+
+@Repository
+public abstract class SimpleCriteriaRepository extends AbstractEntityRepository<Simple, Long>
+ implements CriteriaSupport<Simple>
+{
+
+ public List<Simple> queryByCriteria(String name, Boolean enabled, Integer from, Integer to)
+ {
+ return criteria()
+ .eq(Simple_.name, name)
+ .eq(Simple_.enabled, enabled)
+ .between(Simple_.counter, from, to)
+ .getResultList();
+ }
+
+ @SuppressWarnings("unchecked")
+ public Statistics queryWithSelect(String name)
+ {
+ return criteria()
+ .select(Statistics.class, avg(Simple_.counter), count(Simple_.counter))
+ .eq(Simple_.name, name)
+ .getSingleResult();
+ }
+
+ @SuppressWarnings("unchecked")
+ public Object[] queryWithSelectAggregateReturnArray(String name)
+ {
+ return criteria()
+ .select(min(Simple_.counter), max(Simple_.counter),
+ currDate(), currTime(), currTStamp())
+ .eq(Simple_.name, name)
+ .createQuery()
+ .getSingleResult();
+ }
+
+ @SuppressWarnings("unchecked")
+ public List<Object[]> queryWithSelectAttributes(String name)
+ {
+ return criteria()
+ .select(attribute(Simple_.name),
+ upper(Simple_.name), lower(Simple_.name),
+ substring(Simple_.name, 2), substring(Simple_.name, 2, 2))
+ .eq(Simple_.name, name)
+ .createQuery()
+ .getResultList();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ae1a7147/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/SimpleFetchRepository.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/SimpleFetchRepository.java b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/SimpleFetchRepository.java
new file mode 100644
index 0000000..788b668
--- /dev/null
+++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/SimpleFetchRepository.java
@@ -0,0 +1,28 @@
+/*
+ * 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.deltaspike.data.test.service;
+
+import org.apache.deltaspike.data.api.AbstractEntityRepository;
+import org.apache.deltaspike.data.api.Repository;
+import org.apache.deltaspike.data.test.domain.Simple;
+
+@Repository(methodPrefix = "fetchBy")
+public abstract class SimpleFetchRepository extends AbstractEntityRepository<Simple, Long>
+{
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ae1a7147/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/SimpleRepository.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/SimpleRepository.java b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/SimpleRepository.java
new file mode 100755
index 0000000..21c41cb
--- /dev/null
+++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/SimpleRepository.java
@@ -0,0 +1,84 @@
+/*
+ * 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.deltaspike.data.test.service;
+
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.LockModeType;
+
+import org.apache.deltaspike.data.api.AbstractEntityRepository;
+import org.apache.deltaspike.data.api.FirstResult;
+import org.apache.deltaspike.data.api.MaxResults;
+import org.apache.deltaspike.data.api.Modifying;
+import org.apache.deltaspike.data.api.Query;
+import org.apache.deltaspike.data.api.QueryParam;
+import org.apache.deltaspike.data.api.QueryResult;
+import org.apache.deltaspike.data.api.Repository;
+import org.apache.deltaspike.data.test.domain.Simple;
+
+@Repository
+public abstract class SimpleRepository extends AbstractEntityRepository<Simple, Long>
+{
+
+ public List<Simple> implementedQueryByName(String name)
+ {
+ String query = "select s from Simple s where s.name = :name";
+ return entityManager().createQuery(query, Simple.class)
+ .setParameter("name", name)
+ .getResultList();
+ }
+
+ @Query(named = Simple.BY_NAME_ENABLED, max = 1)
+ public abstract List<Simple> findByNamedQueryIndexed(String name, Boolean enabled);
+
+ @Query(named = Simple.BY_NAME_ENABLED)
+ public abstract List<Simple> findByNamedQueryRestricted(String name, Boolean enabled,
+ @MaxResults int max, @FirstResult Integer first);
+
+ @Query(named = Simple.BY_ID, lock = LockModeType.PESSIMISTIC_WRITE)
+ public abstract Simple findByNamedQueryNamed(
+ @QueryParam("id") Long id, @QueryParam("enabled") Boolean enabled);
+
+ @Query("select s from Simple s where s.name = ?1")
+ public abstract Simple findByQuery(String name);
+
+ @Query("select count(s) from Simple s where s.name = ?1")
+ public abstract Long findCountByQuery(String name);
+
+ public abstract Simple findByNameAndEnabled(String name, Boolean enabled);
+
+ public abstract List<Simple> findByOrderByCounterAscIdDesc();
+
+ @Query(value = "SELECT * from SIMPLE_TABLE s WHERE s.name = ?1", isNative = true)
+ public abstract List<Simple> findWithNative(String name);
+
+ @Modifying
+ @Query("update Simple as s set s.name = ?1 where s.id = ?2")
+ public abstract int updateNameForId(String name, Long id);
+
+ @Query(named = Simple.BY_NAME_LIKE)
+ public abstract QueryResult<Simple> queryResultWithNamed(String name);
+
+ public abstract QueryResult<Simple> findByName(String name);
+
+ @Override
+ protected abstract EntityManager entityManager();
+
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ae1a7147/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/SimpleRepositoryWithEntityManager.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/SimpleRepositoryWithEntityManager.java b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/SimpleRepositoryWithEntityManager.java
new file mode 100644
index 0000000..d6f8ca7
--- /dev/null
+++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/SimpleRepositoryWithEntityManager.java
@@ -0,0 +1,35 @@
+/*
+ * 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.deltaspike.data.test.service;
+
+import java.util.List;
+
+import org.apache.deltaspike.data.api.EntityManagerConfig;
+import org.apache.deltaspike.data.api.EntityRepository;
+import org.apache.deltaspike.data.api.Repository;
+import org.apache.deltaspike.data.test.domain.Simple;
+
+@Repository
+@EntityManagerConfig(entityManagerResolver = SimplisticEntityManagerResolver.class)
+public interface SimpleRepositoryWithEntityManager extends EntityRepository<Simple, Long>
+{
+
+ List<Simple> findByName(String name);
+
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ae1a7147/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/SimpleRepositoryWithOverriddenEntityManager.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/SimpleRepositoryWithOverriddenEntityManager.java b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/SimpleRepositoryWithOverriddenEntityManager.java
new file mode 100644
index 0000000..6111a8d
--- /dev/null
+++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/SimpleRepositoryWithOverriddenEntityManager.java
@@ -0,0 +1,42 @@
+/*
+ * 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.deltaspike.data.test.service;
+
+import java.util.List;
+
+import org.apache.deltaspike.data.api.AbstractEntityRepository;
+import org.apache.deltaspike.data.api.EntityManagerConfig;
+import org.apache.deltaspike.data.api.Repository;
+import org.apache.deltaspike.data.test.domain.Simple;
+
+@EntityManagerConfig(entityManagerResolver = SimplisticEntityManagerResolver.class)
+@Repository
+public abstract class SimpleRepositoryWithOverriddenEntityManager extends AbstractEntityRepository<Simple, Long>
+{
+
+ public abstract List<Simple> findByName(String name);
+
+ public List<Simple> findWithEm(String name)
+ {
+ return entityManager().createQuery("select s from Simple s where s.name = ?1", Simple.class)
+ .setParameter(1, name)
+ .getResultList();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ae1a7147/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/Simplistic.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/Simplistic.java b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/Simplistic.java
new file mode 100644
index 0000000..9b15da3
--- /dev/null
+++ b/deltaspike/modules/data/impl/src/test/java/org/apache/deltaspike/data/test/service/Simplistic.java
@@ -0,0 +1,39 @@
+/*
+ * 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.deltaspike.data.test.service;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Qualifier
+@Target({ TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RUNTIME)
+@Documented
+public @interface Simplistic
+{
+}