7 changed files with 413 additions and 325 deletions
@ -1,146 +1,146 @@ |
|||||||
/* |
/* |
||||||
* Copyright 2009 SpringSource Inc. |
* Copyright 2002-2010 the original author or authors. |
||||||
* |
* |
||||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
* you may not use this file except in compliance with the License. |
* you may not use this file except in compliance with the License. |
||||||
* You may obtain a copy of the License at |
* You may obtain a copy of the License at |
||||||
* |
* |
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* |
* |
||||||
* Unless required by applicable law or agreed to in writing, software |
* Unless required by applicable law or agreed to in writing, software |
||||||
* distributed under the License is distributed on an "AS IS" BASIS, |
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
* See the License for the specific language governing permissions and |
* See the License for the specific language governing permissions and |
||||||
* limitations under the License. |
* limitations under the License. |
||||||
*/ |
*/ |
||||||
|
|
||||||
package org.springframework.mock.staticmock; |
package org.springframework.mock.staticmock; |
||||||
|
|
||||||
import javax.persistence.PersistenceException; |
import javax.persistence.PersistenceException; |
||||||
|
|
||||||
import junit.framework.Assert; |
import junit.framework.Assert; |
||||||
|
|
||||||
import org.junit.Test; |
import org.junit.Test; |
||||||
import org.junit.runner.RunWith; |
import org.junit.runner.RunWith; |
||||||
import org.junit.runners.JUnit4; |
import org.junit.runners.JUnit4; |
||||||
|
|
||||||
import static org.springframework.mock.staticmock.AnnotationDrivenStaticEntityMockingControl.*; |
import static org.springframework.mock.staticmock.AnnotationDrivenStaticEntityMockingControl.*; |
||||||
|
|
||||||
|
|
||||||
/** |
/** |
||||||
* Test for static entity mocking framework. |
* Test for static entity mocking framework. |
||||||
* @author Rod Johnson |
* @author Rod Johnson |
||||||
* @author Ramnivas Laddad |
* @author Ramnivas Laddad |
||||||
* |
* |
||||||
*/ |
*/ |
||||||
@MockStaticEntityMethods |
@MockStaticEntityMethods |
||||||
@RunWith(JUnit4.class) |
@RunWith(JUnit4.class) |
||||||
public class AnnotationDrivenStaticEntityMockingControlTest { |
public class AnnotationDrivenStaticEntityMockingControlTest { |
||||||
|
|
||||||
@Test |
@Test |
||||||
public void testNoArgIntReturn() { |
public void testNoArgIntReturn() { |
||||||
int expectedCount = 13; |
int expectedCount = 13; |
||||||
Person.countPeople(); |
Person.countPeople(); |
||||||
expectReturn(expectedCount); |
expectReturn(expectedCount); |
||||||
playback(); |
playback(); |
||||||
Assert.assertEquals(expectedCount, Person.countPeople()); |
Assert.assertEquals(expectedCount, Person.countPeople()); |
||||||
} |
} |
||||||
|
|
||||||
@Test(expected=PersistenceException.class) |
@Test(expected=PersistenceException.class) |
||||||
public void testNoArgThrows() { |
public void testNoArgThrows() { |
||||||
Person.countPeople(); |
Person.countPeople(); |
||||||
expectThrow(new PersistenceException()); |
expectThrow(new PersistenceException()); |
||||||
playback(); |
playback(); |
||||||
Person.countPeople(); |
Person.countPeople(); |
||||||
} |
} |
||||||
|
|
||||||
@Test |
@Test |
||||||
public void testArgMethodMatches() { |
public void testArgMethodMatches() { |
||||||
long id = 13; |
long id = 13; |
||||||
Person found = new Person(); |
Person found = new Person(); |
||||||
Person.findPerson(id); |
Person.findPerson(id); |
||||||
expectReturn(found); |
expectReturn(found); |
||||||
playback(); |
playback(); |
||||||
Assert.assertEquals(found, Person.findPerson(id)); |
Assert.assertEquals(found, Person.findPerson(id)); |
||||||
} |
} |
||||||
|
|
||||||
|
|
||||||
@Test |
@Test |
||||||
public void testLongSeriesOfCalls() { |
public void testLongSeriesOfCalls() { |
||||||
long id1 = 13; |
long id1 = 13; |
||||||
long id2 = 24; |
long id2 = 24; |
||||||
Person found1 = new Person(); |
Person found1 = new Person(); |
||||||
Person.findPerson(id1); |
Person.findPerson(id1); |
||||||
expectReturn(found1); |
expectReturn(found1); |
||||||
Person found2 = new Person(); |
Person found2 = new Person(); |
||||||
Person.findPerson(id2); |
Person.findPerson(id2); |
||||||
expectReturn(found2); |
expectReturn(found2); |
||||||
Person.findPerson(id1); |
Person.findPerson(id1); |
||||||
expectReturn(found1); |
expectReturn(found1); |
||||||
Person.countPeople(); |
Person.countPeople(); |
||||||
expectReturn(0); |
expectReturn(0); |
||||||
playback(); |
playback(); |
||||||
|
|
||||||
Assert.assertEquals(found1, Person.findPerson(id1)); |
Assert.assertEquals(found1, Person.findPerson(id1)); |
||||||
Assert.assertEquals(found2, Person.findPerson(id2)); |
Assert.assertEquals(found2, Person.findPerson(id2)); |
||||||
Assert.assertEquals(found1, Person.findPerson(id1)); |
Assert.assertEquals(found1, Person.findPerson(id1)); |
||||||
Assert.assertEquals(0, Person.countPeople()); |
Assert.assertEquals(0, Person.countPeople()); |
||||||
} |
} |
||||||
|
|
||||||
// Note delegation is used when tests are invalid and should fail, as otherwise
|
// Note delegation is used when tests are invalid and should fail, as otherwise
|
||||||
// the failure will occur on the verify() method in the aspect after
|
// the failure will occur on the verify() method in the aspect after
|
||||||
// this method returns, failing the test case
|
// this method returns, failing the test case
|
||||||
@Test |
@Test |
||||||
public void testArgMethodNoMatchExpectReturn() { |
public void testArgMethodNoMatchExpectReturn() { |
||||||
try { |
try { |
||||||
new Delegate().testArgMethodNoMatchExpectReturn(); |
new Delegate().testArgMethodNoMatchExpectReturn(); |
||||||
Assert.fail(); |
Assert.fail(); |
||||||
} catch (IllegalArgumentException expected) { |
} catch (IllegalArgumentException expected) { |
||||||
} |
} |
||||||
} |
} |
||||||
|
|
||||||
@Test(expected=IllegalArgumentException.class) |
@Test(expected=IllegalArgumentException.class) |
||||||
public void testArgMethodNoMatchExpectThrow() { |
public void testArgMethodNoMatchExpectThrow() { |
||||||
new Delegate().testArgMethodNoMatchExpectThrow(); |
new Delegate().testArgMethodNoMatchExpectThrow(); |
||||||
} |
} |
||||||
|
|
||||||
private void called(Person found, long id) { |
private void called(Person found, long id) { |
||||||
Assert.assertEquals(found, Person.findPerson(id)); |
Assert.assertEquals(found, Person.findPerson(id)); |
||||||
} |
} |
||||||
|
|
||||||
@Test |
@Test |
||||||
public void testReentrant() { |
public void testReentrant() { |
||||||
long id = 13; |
long id = 13; |
||||||
Person found = new Person(); |
Person found = new Person(); |
||||||
Person.findPerson(id); |
Person.findPerson(id); |
||||||
expectReturn(found); |
expectReturn(found); |
||||||
playback(); |
playback(); |
||||||
called(found, id); |
called(found, id); |
||||||
} |
} |
||||||
|
|
||||||
@Test(expected=IllegalStateException.class) |
@Test(expected=IllegalStateException.class) |
||||||
public void testRejectUnexpectedCall() { |
public void testRejectUnexpectedCall() { |
||||||
new Delegate().rejectUnexpectedCall(); |
new Delegate().rejectUnexpectedCall(); |
||||||
} |
} |
||||||
|
|
||||||
@Test(expected=IllegalStateException.class) |
@Test(expected=IllegalStateException.class) |
||||||
public void testFailTooFewCalls() { |
public void testFailTooFewCalls() { |
||||||
new Delegate().failTooFewCalls(); |
new Delegate().failTooFewCalls(); |
||||||
} |
} |
||||||
|
|
||||||
@Test |
@Test |
||||||
public void testEmpty() { |
public void testEmpty() { |
||||||
// Test that verification check doesn't blow up if no replay() call happened
|
// Test that verification check doesn't blow up if no replay() call happened
|
||||||
} |
} |
||||||
|
|
||||||
@Test(expected=IllegalStateException.class) |
@Test(expected=IllegalStateException.class) |
||||||
public void testDoesntEverReplay() { |
public void testDoesntEverReplay() { |
||||||
new Delegate().doesntEverReplay(); |
new Delegate().doesntEverReplay(); |
||||||
} |
} |
||||||
|
|
||||||
@Test(expected=IllegalStateException.class) |
@Test(expected=IllegalStateException.class) |
||||||
public void testDoesntEverSetReturn() { |
public void testDoesntEverSetReturn() { |
||||||
new Delegate().doesntEverSetReturn(); |
new Delegate().doesntEverSetReturn(); |
||||||
} |
} |
||||||
} |
} |
||||||
|
|
||||||
|
|||||||
@ -1,76 +1,92 @@ |
|||||||
package org.springframework.mock.staticmock; |
/* |
||||||
|
* Copyright 2002-2010 the original author or authors. |
||||||
import java.rmi.RemoteException; |
* |
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
import javax.persistence.PersistenceException; |
* you may not use this file except in compliance with the License. |
||||||
|
* You may obtain a copy of the License at |
||||||
import junit.framework.Assert; |
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
import org.junit.Ignore; |
* |
||||||
import org.junit.Test; |
* Unless required by applicable law or agreed to in writing, software |
||||||
import org.springframework.mock.staticmock.AnnotationDrivenStaticEntityMockingControl; |
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
import org.springframework.mock.staticmock.MockStaticEntityMethods; |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
//Used because verification failures occur after method returns,
|
* limitations under the License. |
||||||
//so we can't test for them in the test case itself
|
*/ |
||||||
@MockStaticEntityMethods |
|
||||||
@Ignore // This isn't meant for direct testing; rather it is driven from AnnotationDrivenStaticEntityMockingControl
|
package org.springframework.mock.staticmock; |
||||||
public class Delegate { |
|
||||||
|
import java.rmi.RemoteException; |
||||||
@Test |
|
||||||
public void testArgMethodNoMatchExpectReturn() { |
import javax.persistence.PersistenceException; |
||||||
long id = 13; |
|
||||||
Person found = new Person(); |
import junit.framework.Assert; |
||||||
Person.findPerson(id); |
|
||||||
AnnotationDrivenStaticEntityMockingControl.expectReturn(found); |
import org.junit.Ignore; |
||||||
AnnotationDrivenStaticEntityMockingControl.playback(); |
import org.junit.Test; |
||||||
Assert.assertEquals(found, Person.findPerson(id + 1)); |
import org.springframework.mock.staticmock.AnnotationDrivenStaticEntityMockingControl; |
||||||
} |
import org.springframework.mock.staticmock.MockStaticEntityMethods; |
||||||
|
|
||||||
@Test |
//Used because verification failures occur after method returns,
|
||||||
public void testArgMethodNoMatchExpectThrow() { |
//so we can't test for them in the test case itself
|
||||||
long id = 13; |
@MockStaticEntityMethods |
||||||
Person found = new Person(); |
@Ignore // This isn't meant for direct testing; rather it is driven from AnnotationDrivenStaticEntityMockingControl
|
||||||
Person.findPerson(id); |
public class Delegate { |
||||||
AnnotationDrivenStaticEntityMockingControl.expectThrow(new PersistenceException()); |
|
||||||
AnnotationDrivenStaticEntityMockingControl.playback(); |
@Test |
||||||
Assert.assertEquals(found, Person.findPerson(id + 1)); |
public void testArgMethodNoMatchExpectReturn() { |
||||||
} |
long id = 13; |
||||||
|
Person found = new Person(); |
||||||
@Test |
Person.findPerson(id); |
||||||
public void failTooFewCalls() { |
AnnotationDrivenStaticEntityMockingControl.expectReturn(found); |
||||||
long id = 13; |
AnnotationDrivenStaticEntityMockingControl.playback(); |
||||||
Person found = new Person(); |
Assert.assertEquals(found, Person.findPerson(id + 1)); |
||||||
Person.findPerson(id); |
} |
||||||
AnnotationDrivenStaticEntityMockingControl.expectReturn(found); |
|
||||||
Person.countPeople(); |
@Test |
||||||
AnnotationDrivenStaticEntityMockingControl.expectReturn(25); |
public void testArgMethodNoMatchExpectThrow() { |
||||||
AnnotationDrivenStaticEntityMockingControl.playback(); |
long id = 13; |
||||||
Assert.assertEquals(found, Person.findPerson(id)); |
Person found = new Person(); |
||||||
} |
Person.findPerson(id); |
||||||
|
AnnotationDrivenStaticEntityMockingControl.expectThrow(new PersistenceException()); |
||||||
@Test |
AnnotationDrivenStaticEntityMockingControl.playback(); |
||||||
public void doesntEverReplay() { |
Assert.assertEquals(found, Person.findPerson(id + 1)); |
||||||
Person.countPeople(); |
} |
||||||
} |
|
||||||
|
@Test |
||||||
@Test |
public void failTooFewCalls() { |
||||||
public void doesntEverSetReturn() { |
long id = 13; |
||||||
Person.countPeople(); |
Person found = new Person(); |
||||||
AnnotationDrivenStaticEntityMockingControl.playback(); |
Person.findPerson(id); |
||||||
} |
AnnotationDrivenStaticEntityMockingControl.expectReturn(found); |
||||||
|
Person.countPeople(); |
||||||
@Test |
AnnotationDrivenStaticEntityMockingControl.expectReturn(25); |
||||||
public void rejectUnexpectedCall() { |
AnnotationDrivenStaticEntityMockingControl.playback(); |
||||||
AnnotationDrivenStaticEntityMockingControl.playback(); |
Assert.assertEquals(found, Person.findPerson(id)); |
||||||
Person.countPeople(); |
} |
||||||
} |
|
||||||
|
@Test |
||||||
@Test(expected=RemoteException.class) |
public void doesntEverReplay() { |
||||||
public void testVerificationFailsEvenWhenTestFailsInExpectedManner() throws RemoteException { |
Person.countPeople(); |
||||||
Person.countPeople(); |
} |
||||||
AnnotationDrivenStaticEntityMockingControl.playback(); |
|
||||||
// No calls to allow verification failure
|
@Test |
||||||
throw new RemoteException(); |
public void doesntEverSetReturn() { |
||||||
} |
Person.countPeople(); |
||||||
} |
AnnotationDrivenStaticEntityMockingControl.playback(); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void rejectUnexpectedCall() { |
||||||
|
AnnotationDrivenStaticEntityMockingControl.playback(); |
||||||
|
Person.countPeople(); |
||||||
|
} |
||||||
|
|
||||||
|
@Test(expected=RemoteException.class) |
||||||
|
public void testVerificationFailsEvenWhenTestFailsInExpectedManner() throws RemoteException { |
||||||
|
Person.countPeople(); |
||||||
|
AnnotationDrivenStaticEntityMockingControl.playback(); |
||||||
|
// No calls to allow verification failure
|
||||||
|
throw new RemoteException(); |
||||||
|
} |
||||||
|
} |
||||||
|
|||||||
@ -1,8 +1,24 @@ |
|||||||
package org.springframework.mock.staticmock; |
/* |
||||||
|
* Copyright 2002-2010 the original author or authors. |
||||||
import javax.persistence.Entity; |
* |
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
@Entity |
* you may not use this file except in compliance with the License. |
||||||
public class Person { |
* 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.springframework.mock.staticmock; |
||||||
|
|
||||||
|
import javax.persistence.Entity; |
||||||
|
|
||||||
|
@Entity |
||||||
|
public class Person { |
||||||
|
} |
||||||
|
|
||||||
|
|||||||
@ -1,84 +1,100 @@ |
|||||||
package org.springframework.mock.staticmock; |
/* |
||||||
|
* Copyright 2002-2010 the original author or authors. |
||||||
privileged aspect Person_Roo_Entity { |
* |
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
@javax.persistence.PersistenceContext |
* you may not use this file except in compliance with the License. |
||||||
transient javax.persistence.EntityManager Person.entityManager; |
* You may obtain a copy of the License at |
||||||
|
* |
||||||
@javax.persistence.Id |
* http://www.apache.org/licenses/LICENSE-2.0 |
||||||
@javax.persistence.GeneratedValue(strategy = javax.persistence.GenerationType.AUTO) |
* |
||||||
@javax.persistence.Column(name = "id") |
* Unless required by applicable law or agreed to in writing, software |
||||||
private java.lang.Long Person.id; |
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
@javax.persistence.Version |
* See the License for the specific language governing permissions and |
||||||
@javax.persistence.Column(name = "version") |
* limitations under the License. |
||||||
private java.lang.Integer Person.version; |
*/ |
||||||
|
|
||||||
public java.lang.Long Person.getId() { |
package org.springframework.mock.staticmock; |
||||||
return this.id; |
|
||||||
} |
privileged aspect Person_Roo_Entity { |
||||||
|
|
||||||
public void Person.setId(java.lang.Long id) { |
@javax.persistence.PersistenceContext |
||||||
this.id = id; |
transient javax.persistence.EntityManager Person.entityManager; |
||||||
} |
|
||||||
|
@javax.persistence.Id |
||||||
public java.lang.Integer Person.getVersion() { |
@javax.persistence.GeneratedValue(strategy = javax.persistence.GenerationType.AUTO) |
||||||
return this.version; |
@javax.persistence.Column(name = "id") |
||||||
} |
private java.lang.Long Person.id; |
||||||
|
|
||||||
public void Person.setVersion(java.lang.Integer version) { |
@javax.persistence.Version |
||||||
this.version = version; |
@javax.persistence.Column(name = "version") |
||||||
} |
private java.lang.Integer Person.version; |
||||||
|
|
||||||
@org.springframework.transaction.annotation.Transactional |
public java.lang.Long Person.getId() { |
||||||
public void Person.persist() { |
return this.id; |
||||||
if (this.entityManager == null) throw new IllegalStateException("Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)"); |
} |
||||||
this.entityManager.persist(this); |
|
||||||
} |
public void Person.setId(java.lang.Long id) { |
||||||
|
this.id = id; |
||||||
@org.springframework.transaction.annotation.Transactional |
} |
||||||
public void Person.remove() { |
|
||||||
if (this.entityManager == null) throw new IllegalStateException("Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)"); |
public java.lang.Integer Person.getVersion() { |
||||||
this.entityManager.remove(this); |
return this.version; |
||||||
} |
} |
||||||
|
|
||||||
@org.springframework.transaction.annotation.Transactional |
public void Person.setVersion(java.lang.Integer version) { |
||||||
public void Person.flush() { |
this.version = version; |
||||||
if (this.entityManager == null) throw new IllegalStateException("Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)"); |
} |
||||||
this.entityManager.flush(); |
|
||||||
} |
@org.springframework.transaction.annotation.Transactional |
||||||
|
public void Person.persist() { |
||||||
@org.springframework.transaction.annotation.Transactional |
if (this.entityManager == null) throw new IllegalStateException("Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)"); |
||||||
public void Person.merge() { |
this.entityManager.persist(this); |
||||||
if (this.entityManager == null) throw new IllegalStateException("Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)"); |
} |
||||||
Person merged = this.entityManager.merge(this); |
|
||||||
this.entityManager.flush(); |
@org.springframework.transaction.annotation.Transactional |
||||||
this.id = merged.getId(); |
public void Person.remove() { |
||||||
} |
if (this.entityManager == null) throw new IllegalStateException("Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)"); |
||||||
|
this.entityManager.remove(this); |
||||||
public static long Person.countPeople() { |
} |
||||||
javax.persistence.EntityManager em = new Person().entityManager; |
|
||||||
if (em == null) throw new IllegalStateException("Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)"); |
@org.springframework.transaction.annotation.Transactional |
||||||
return (Long) em.createQuery("select count(o) from Person o").getSingleResult(); |
public void Person.flush() { |
||||||
} |
if (this.entityManager == null) throw new IllegalStateException("Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)"); |
||||||
|
this.entityManager.flush(); |
||||||
public static java.util.List<Person> Person.findAllPeople() { |
} |
||||||
javax.persistence.EntityManager em = new Person().entityManager; |
|
||||||
if (em == null) throw new IllegalStateException("Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)"); |
@org.springframework.transaction.annotation.Transactional |
||||||
return em.createQuery("select o from Person o").getResultList(); |
public void Person.merge() { |
||||||
} |
if (this.entityManager == null) throw new IllegalStateException("Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)"); |
||||||
|
Person merged = this.entityManager.merge(this); |
||||||
public static Person Person.findPerson(java.lang.Long id) { |
this.entityManager.flush(); |
||||||
if (id == null) throw new IllegalArgumentException("An identifier is required to retrieve an instance of Person"); |
this.id = merged.getId(); |
||||||
javax.persistence.EntityManager em = new Person().entityManager; |
} |
||||||
if (em == null) throw new IllegalStateException("Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)"); |
|
||||||
return em.find(Person.class, id); |
public static long Person.countPeople() { |
||||||
} |
javax.persistence.EntityManager em = new Person().entityManager; |
||||||
|
if (em == null) throw new IllegalStateException("Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)"); |
||||||
public static java.util.List<Person> Person.findPersonEntries(int firstResult, int maxResults) { |
return (Long) em.createQuery("select count(o) from Person o").getSingleResult(); |
||||||
javax.persistence.EntityManager em = new Person().entityManager; |
} |
||||||
if (em == null) throw new IllegalStateException("Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)"); |
|
||||||
return em.createQuery("select o from Person o").setFirstResult(firstResult).setMaxResults(maxResults).getResultList(); |
public static java.util.List<Person> Person.findAllPeople() { |
||||||
} |
javax.persistence.EntityManager em = new Person().entityManager; |
||||||
|
if (em == null) throw new IllegalStateException("Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)"); |
||||||
} |
return em.createQuery("select o from Person o").getResultList(); |
||||||
|
} |
||||||
|
|
||||||
|
public static Person Person.findPerson(java.lang.Long id) { |
||||||
|
if (id == null) throw new IllegalArgumentException("An identifier is required to retrieve an instance of Person"); |
||||||
|
javax.persistence.EntityManager em = new Person().entityManager; |
||||||
|
if (em == null) throw new IllegalStateException("Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)"); |
||||||
|
return em.find(Person.class, id); |
||||||
|
} |
||||||
|
|
||||||
|
public static java.util.List<Person> Person.findPersonEntries(int firstResult, int maxResults) { |
||||||
|
javax.persistence.EntityManager em = new Person().entityManager; |
||||||
|
if (em == null) throw new IllegalStateException("Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)"); |
||||||
|
return em.createQuery("select o from Person o").setFirstResult(firstResult).setMaxResults(maxResults).getResultList(); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|||||||
Loading…
Reference in new issue