OPENJPA-1597 New tests to verify expected behavior for proposed Compatibility fix.

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@927427 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Donald Woods 2010-03-25 14:43:41 +00:00
parent 666ec6c6de
commit e88899d3a1
36 changed files with 2450 additions and 0 deletions

View File

@ -0,0 +1,780 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.openjpa.persistence.proxy;
import java.math.BigDecimal;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import javax.persistence.EntityManager;
import org.apache.openjpa.conf.Compatibility;
import org.apache.openjpa.lib.log.Log;
import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
import org.apache.openjpa.persistence.OpenJPAPersistence;
import org.apache.openjpa.persistence.test.AllowFailure;
import org.apache.openjpa.persistence.test.SingleEMFTestCase;
import org.apache.openjpa.persistence.proxy.entities.Address;
import org.apache.openjpa.persistence.proxy.entities.AnnuityHolderCategory;
import org.apache.openjpa.persistence.proxy.entities.AnnuityPersistebleObject;
import org.apache.openjpa.persistence.proxy.entities.ContactType;
import org.apache.openjpa.persistence.proxy.entities.IAnnuity;
import org.apache.openjpa.persistence.proxy.entities.IAnnuityHolder;
import org.apache.openjpa.persistence.proxy.entities.IContact;
import org.apache.openjpa.persistence.proxy.entities.IEquityAnnuity;
import org.apache.openjpa.persistence.proxy.entities.IFixedAnnuity;
import org.apache.openjpa.persistence.proxy.entities.IPayor;
import org.apache.openjpa.persistence.proxy.entities.IPayout;
import org.apache.openjpa.persistence.proxy.entities.IRider;
import org.apache.openjpa.persistence.proxy.entities.Person;
import org.apache.openjpa.persistence.proxy.entities.RiderType;
import org.apache.openjpa.persistence.proxy.entities.Annuity;
import org.apache.openjpa.persistence.proxy.entities.AnnuityHolder;
import org.apache.openjpa.persistence.proxy.entities.Contact;
import org.apache.openjpa.persistence.proxy.entities.EquityAnnuity;
import org.apache.openjpa.persistence.proxy.entities.FixedAnnuity;
import org.apache.openjpa.persistence.proxy.entities.Payor;
import org.apache.openjpa.persistence.proxy.entities.Payout;
import org.apache.openjpa.persistence.proxy.entities.Rider;
import org.apache.openjpa.persistence.proxy.entities.AnnuityType;
/*
* Test the complicated interaction between Detached entities, Proxy classes
* and Merging changes made in ProxyCollections back into entities.
*
* This code is based on AcmeTest2, which was originally written by
* Mohammad at IBM and contributed under ASL 2.0.
*/
public class TestDetachMerge extends SingleEMFTestCase {
public void setUp() {
setUp(DROP_TABLES, Address.class, Annuity.class, AnnuityHolder.class, AnnuityPersistebleObject.class,
Contact.class, EquityAnnuity.class, FixedAnnuity.class, Payor.class, Payout.class,
Person.class, Rider.class);
}
/*
* Test default 1.0 compatibility behavior, which should pass AS-IS
*/
@AllowFailure(message="Will fail until OPENJPA-1597 is fixed")
public void testAnnuity1Compat() throws Exception {
OpenJPAEntityManagerFactorySPI emf1 =
(OpenJPAEntityManagerFactorySPI) OpenJPAPersistence.createEntityManagerFactory(
"Annuity1Compat", "org/apache/openjpa/persistence/proxy/persistence1.xml");
assertNotNull(emf1);
Log log = emf1.getConfiguration().getLog("test");
if (log.isTraceEnabled()) {
Compatibility compat = emf1.getConfiguration().getCompatibilityInstance();
assertNotNull(compat);
log.trace("started testAnnuity1Compat()");
log.trace("FlushBeforeDetach=" + compat.getFlushBeforeDetach());
log.trace("CopyOnDetach=" + compat.getCopyOnDetach());
log.trace("CascadeWithDetach=" + compat.getCascadeWithDetach());
}
try {
execute(emf1);
} catch (RuntimeException e) {
fail("testAnuity1Compat() should not have caused an execption!" + e);
} finally {
emf1.close();
}
}
/*
* Test 2.0 behavior with Compatibility flag and DetachedStateField=true, which should PASS
*/
@AllowFailure(message="Will fail until OPENJPA-1597 is fixed")
public void testAnnuity2Compat() throws Exception {
OpenJPAEntityManagerFactorySPI emf2 =
(OpenJPAEntityManagerFactorySPI) OpenJPAPersistence.createEntityManagerFactory(
"Annuity2Compat", "org/apache/openjpa/persistence/proxy/persistence2.xml");
assertNotNull(emf2);
Log log = emf2.getConfiguration().getLog("test");
if (log.isTraceEnabled()) {
Compatibility compat = emf2.getConfiguration().getCompatibilityInstance();
assertNotNull(compat);
log.trace("started testAnnuity2Compat()");
log.trace("FlushBeforeDetach=" + compat.getFlushBeforeDetach());
log.trace("CopyOnDetach=" + compat.getCopyOnDetach());
log.trace("CascadeWithDetach=" + compat.getCascadeWithDetach());
}
try {
execute(emf2);
} catch (RuntimeException e) {
fail("testAnuity2Compat() should not have caused an execption!" + e);
} finally {
emf2.close();
}
}
/*
* Test 2.0 behavior with DetachedStateField=true, which should FAIL
*/
public void testAnnuity2Fail() throws Exception {
OpenJPAEntityManagerFactorySPI emf2 =
(OpenJPAEntityManagerFactorySPI) OpenJPAPersistence.createEntityManagerFactory(
"Annuity2Fail", "org/apache/openjpa/persistence/proxy/persistence2.xml");
assertNotNull(emf2);
Log log = emf2.getConfiguration().getLog("test");
if (log.isTraceEnabled()) {
Compatibility compat = emf2.getConfiguration().getCompatibilityInstance();
assertNotNull(compat);
log.trace("started testAnnuity2Fail()");
log.trace("FlushBeforeDetach=" + compat.getFlushBeforeDetach());
log.trace("CopyOnDetach=" + compat.getCopyOnDetach());
log.trace("CascadeWithDetach=" + compat.getCascadeWithDetach());
}
try {
execute(emf2);
fail("testAnuity2Fail() should have caused an execption!");
} catch (RuntimeException e) {
if (e.getMessage().startsWith("Annuity:")) {
// no-op caught our expected exception
} else {
fail("testAnuity2Fail() caught an unexpected execption!" + e);
}
} finally {
emf2.close();
}
}
/*
* Test default 2.0 behavior with DetachedStateField=transient, which should PASS
*/
public void testAnnuity2New() throws Exception {
OpenJPAEntityManagerFactorySPI emf2 =
(OpenJPAEntityManagerFactorySPI) OpenJPAPersistence.createEntityManagerFactory(
"Annuity2New", "org/apache/openjpa/persistence/proxy/persistence2.xml");
assertNotNull(emf2);
Log log = emf2.getConfiguration().getLog("test");
if (log.isTraceEnabled()) {
Compatibility compat = emf2.getConfiguration().getCompatibilityInstance();
assertNotNull(compat);
log.trace("started testAnnuity2New()");
log.trace("FlushBeforeDetach=" + compat.getFlushBeforeDetach());
log.trace("CopyOnDetach=" + compat.getCopyOnDetach());
log.trace("CascadeWithDetach=" + compat.getCascadeWithDetach());
}
try {
execute(emf2);
} catch (RuntimeException e) {
fail("testAnuity2New() should not have caused an execption!" + e);
} finally {
emf2.close();
}
}
private void execute(OpenJPAEntityManagerFactorySPI myEMF) throws Exception {
Log log = myEMF.getConfiguration().getLog("test");
//EntityManager em = myEMF.createEntityManager();
IContact contact = null;
try {
if (log.isTraceEnabled())
log.trace("creating contact");
try {
contact = createContact(myEMF);
} catch (Exception e) {
log.error("Create Contact failed.", e);
throw e;
}
try {
verifyContactValues(myEMF, contact);
} catch (Exception e) {
log.error("Create Contact verification failed.", e);
throw e;
// do not return, as this might be a small bug that we can bypass
}
if (log.isTraceEnabled())
log.trace("creating annuity holder");
IAnnuityHolder annuityHolder = null;
try {
annuityHolder = createAnnuityHolder(myEMF, contact);
} catch (Exception e) {
log.error("failed to create Annuity Holder Successfully.", e);
throw e;
}
try {
verifyAnnuityHolderValues(myEMF, annuityHolder);
} catch (Exception e) {
log.info("failed to verify create annuity holder successfuly.", e);
throw e;
}
if (log.isTraceEnabled())
log.trace("creating payor");
IPayor payor = null;
try {
payor = createPayor(myEMF);
} catch(Exception e) {
log.error("failed to create payor successfuly.", e);
throw e;
}
try {
verifyPayorValues(myEMF, payor);
} catch (Exception e) {
log.error("failed to verify create payor successfuly.", e);
throw e;
}
if (log.isTraceEnabled())
log.trace("creating annuity");
IAnnuity annuity =null;
AnnuityType annuityType = AnnuityType.FIXED;
try {
annuity = createAnnuityWithRider(myEMF, annuityType);
} catch (Exception e) {
log.error("failed to create annuity successfuly.", e);
throw e;
}
try {
log.trace("verify annuity with rider");
verifyAnnuityValues(myEMF, annuity, annuityType);
} catch (Exception e) {
log.error("failed to verify create annuity successfuly.", e);
throw e;
}
if (log.isTraceEnabled())
log.trace("upating annuity");
try {
log.trace("create annuity with payout");
annuity = createAnnuityPayout(myEMF, annuity);
} catch (Exception e) {
log.error("failed to create annuity successfuly.", e);
throw e;
}
try {
verifyAnnuityValues(myEMF, annuity, annuityType);
} catch (Exception e) {
log.error("failed to verify create annuity successfuly.", e);
throw e;
}
if (log.isTraceEnabled())
log.trace("upating annuity");
try {
EntityManager em = createEM(myEMF);
em.getTransaction().begin();
annuity.getPayors().add(payor);
annuity.setAnnuityHolderId(annuityHolder.getId());
annuity = em.merge(annuity);
em.getTransaction().commit();
closeEM(em);
} catch (Exception e) {
log.error("failed to update annuity successfuly.", e);
throw e;
}
try {
verifyAnnuityValues(myEMF, annuity, annuityType);
} catch (Exception e) {
log.error("failed to verify annuity update successfuly.", e);
throw e;
}
} finally {
log.error("scenario: failed.");
}
if (log.isTraceEnabled())
log.trace("scenario: completed.");
}
private IAnnuity createAnnuityPayout(OpenJPAEntityManagerFactorySPI myEMF, IAnnuity annuity) {
EntityManager em = createEM(myEMF);
em.getTransaction().begin();
IPayout payout = new Payout();
payout.setAnnuity(annuity);
payout.setTaxableAmount(new BigDecimal(100.00));
payout.setStartDate(Calendar.getInstance());
payout.setEndDate(Calendar.getInstance());
payout.setId(getId());
em.persist(payout);
em.getTransaction().commit();
em.getTransaction().begin();
annuity.getPayouts().add(payout);
em.getTransaction().commit();
closeEM(em);
return annuity;
}
private IAnnuity createAnnuityWithRider(OpenJPAEntityManagerFactorySPI myEMF, AnnuityType annuityType) {
EntityManager em = createEM(myEMF);
em.getTransaction().begin();
IAnnuity annuity = createAnnuity(annuityType);
IRider rider1 = getRider();
IRider rider2 = getRider();
IRider rider3 = getRider();
annuity.getRiders().add(rider1);
annuity.getRiders().add(rider2);
annuity.getRiders().add(rider3);
em.persist(annuity);
em.getTransaction().commit();
closeEM(em);
return annuity;
}
private IAnnuity createAnnuity(AnnuityType annuityType) {
if (AnnuityType.BASIC.equals(annuityType)) {
Annuity annuity = new Annuity();
annuity.setId(getId());
annuity.setAmount(500.00);
annuity.setAccountNumber("123456");
return annuity;
}
if (AnnuityType.EQUITY.equals(annuityType)) {
EquityAnnuity annuity = new EquityAnnuity();
annuity.setId(getId());
annuity.setAmount(500.00);
annuity.setAccountNumber("123456");
annuity.setFundNames("Something nothing wrong");
annuity.setIndexRate(10.99);
annuity.setLastPaidAmt(100.00);
return annuity;
}
if (AnnuityType.FIXED.equals(annuityType)) {
FixedAnnuity annuity = new FixedAnnuity();
((FixedAnnuity)annuity).setRate(10.0);
annuity.setId(getId());
annuity.setAmount(500.00);
annuity.setAccountNumber("123456");
return annuity;
}
return null;
}
private IRider getRider() {
IRider rider = new Rider();
rider.setId(getId());
rider.setRule("Pay");
rider.setType(RiderType.REPLACE);
rider.setEffectiveDate(new Date());
return rider;
}
private void verifyAnnuityValues(OpenJPAEntityManagerFactorySPI myEMF, IAnnuity annuity, AnnuityType annuityType)
throws Exception {
IAnnuity results = findAnnuityById(myEMF, Annuity.class, annuity.getId());
if (annuity instanceof IFixedAnnuity) {
assertEqual((IFixedAnnuity)annuity, (IFixedAnnuity)results,
"Fixed Annuity from Client is not equal to DB value", "Mismacth was found.");
} else if (annuity instanceof IEquityAnnuity) {
assertEqual((IEquityAnnuity)annuity, (IEquityAnnuity)results,
"Equity Annuity from Client is not equal to DB value", "Mismacth was found.");
} else {
assertEqual(annuity, results,
"Basic Annuity from Client is not equal to DB value", "Mismacth was found.");
}
assertEqual(annuity.getPayouts(), results.getPayouts(),
"Annuity payouts from Client is not equal to DB value", "Mismacth was found in number of payouts");
boolean found = false;
if (annuity.getPayouts() != null) {
IPayout clientPayout = null;
for (int i=0; i<annuity.getPayouts().size(); i++) {
found = false; // reset
clientPayout = annuity.getPayouts().get(i);
for (IPayout resultPayout: results.getPayouts()) {
if (clientPayout.getId().equals(resultPayout.getId())){
found = true;
assertEqual(clientPayout, resultPayout,
"Annuity Payout from Client is not equal to DB value at location: " +i , "Mismacth was found");
}else{
continue;
}
}
if (!(found) && clientPayout != null) {
throw new RuntimeException("Annuity: Payout from client is not equal to DB. " +
"Found Payout with id: " + clientPayout.getId() +
" on the client side, but not in the database for annuity id:" + annuity.getId());
}
}
}
assertRidersEqual(annuity.getRiders(), results.getRiders(),
"Annuity rider from Client is not equal to DB value", "Mismacth was found in number of rider");
if (annuity.getRiders() != null) {
IRider clientRider = null;
for (int i=0; i<annuity.getRiders().size(); i++) {
found = false; // reset
clientRider = annuity.getRiders().get(i);
for (IRider resultRider : results.getRiders()) {
if (clientRider.getId().equals(resultRider.getId())){
found = true;
assertEqual(clientRider, resultRider,
"Annuity rider from Client is not equal to DB value at location: " +i , "Mismacth was found");
}else{
continue;
}
}
if (!(found) && clientRider != null) {
throw new RuntimeException("Annuity: Rider from client is not equal to DB. " +
"Found rider with id: " + clientRider.getId() +
" on the client side, but not in the database for annuity id:" + annuity.getId());
}
}
}
assertPayorsEqual(annuity.getPayors(), results.getPayors(),
"Annuity Payor from Client is not equal to DB value", "Mismacth was found.");
if (annuity.getPayors() != null) {
IPayor clientPayor = null;
for (int i=0; i<annuity.getPayors().size(); i++) {
found = false; // reset
clientPayor = annuity.getPayors().get(i);
for (IPayor resultPayor : results.getPayors()) {
if (clientPayor.getId().equals(resultPayor.getId())){
found = true;
assertEqual(annuity.getPayors().get(i), resultPayor,
"Annuity payor from Client is not equal to DB value at location: " +i , "Mismacth was found");
}else{
continue;
}
}
if (!(found) && clientPayor != null) {
throw new RuntimeException("Annuity: Payor from client is not equal to DB. " +
"Found payor with id: " + clientPayor.getId() +
" on the client side, but not in the database for annuity id:" + annuity.getId());
}
}
}
}
private void assertEqual(IAnnuity annuity, IAnnuity results, String string, String string2) throws Exception {
if(annuity == null && results == null)
return;
if (annuity == null)
throw new RuntimeException("Annuity: Annuities ! equal (Annuity was null).");
if (!annuity.getId().equals(results.getId())) {
throw new RuntimeException("Annuity: Annuities ! equal (Annuity ids not the same).");
}
assertPayorsEqual(annuity.getPayors(), results.getPayors(), string, string2);
assertRidersEqual(annuity.getRiders(), results.getRiders(), string, string2);
assertEqual(annuity.getPayouts(),results.getPayouts(), string, string2);
}
private void assertEqual(IEquityAnnuity annuity, IEquityAnnuity results, String string, String string2)
throws Exception {
if(annuity == null && results == null)
return;
if (annuity == null)
throw new RuntimeException("Annuity: Annuities ! equal (EquityAnnuity was null).");
if (!annuity.getId().equals(results.getId())) {
throw new RuntimeException("Annuity: Annuities ! equal (EquityAnnuity ids not the same).");
}
assertPayorsEqual(annuity.getPayors(), results.getPayors(), string, string2);
assertRidersEqual(annuity.getRiders(), results.getRiders(), string, string2);
assertEqual(annuity.getPayouts(),results.getPayouts(), string, string2);
}
private void assertEqual(IFixedAnnuity annuity, IFixedAnnuity results, String string, String string2)
throws Exception {
if(annuity == null && results == null)
return;
if (annuity == null)
throw new RuntimeException("Annuity: Annuities ! equal (FixedAnnuity was null).");
if (!annuity.getId().equals(results.getId())) {
throw new RuntimeException("Annuity: Annuities ! equal (FixedAnnuity ids not the same).");
}
assertPayorsEqual(annuity.getPayors(), results.getPayors(), string, string2);
assertRidersEqual(annuity.getRiders(), results.getRiders(), string, string2);
assertEqual(annuity.getPayouts(),results.getPayouts(), string, string2);
}
private IAnnuity findAnnuityById(OpenJPAEntityManagerFactorySPI myEMF, Class<Annuity> class1, String id) {
EntityManager em = createEM(myEMF);
IAnnuity ann = em.find(class1, id);
closeEM(em);
return ann;
}
private void assertEqual(List<IPayout> payouts, List<IPayout> payouts2, String string, String string2)
throws Exception {
if (payouts == null && payouts2 == null)
return;
if (payouts == null)
throw new RuntimeException("Annuity: IPayout list not the same (payouts was null)!");
if (payouts.size() != payouts2.size())
throw new RuntimeException("Annuity: IPayout list not the same (payouts size not the same)!");
for (int i = 0; i < payouts.size(); i++) {
IPayout payout = payouts.get(i);
boolean found = false;
for (int j = 0; i < payouts2.size(); j++) {
try {
assertEqual(payout, payouts2.get(j), string, string2);
found = true;
break;
} catch (Exception e) {
continue;
}
}
if (!found) {
throw new RuntimeException("Annuity: IPayout list not the same (no match found)!");
}
}
}
private void assertEqual(IPayout clientPayout, IPayout resultPayout, String string, String string2)
throws Exception {
if (clientPayout == null && resultPayout == null)
return;
if (clientPayout == null)
throw new RuntimeException("Annuity: IPayout not the same (clientPayout was null)! " +
string + " " + string2);
if (clientPayout.getId().equals(resultPayout.getId()))
return;
throw new RuntimeException("Annuity: IPayout not the same (clientPayout ids not the same)! " +
string + " " + string2);
}
private void assertRidersEqual(List<IRider> riders, List<IRider> riders2, String string, String string2)
throws Exception {
if (riders == null && riders2 == null)
return;
if (riders == null)
throw new RuntimeException("Annuity: IRider list not the same (riders was null)!");
if (riders.size() != riders2.size())
throw new RuntimeException("Annuity: IRider list not the same (riders size not the same)!");
for (int i = 0; i < riders.size(); i++) {
IRider rider = riders.get(i);
boolean found = false;
for (int j = 0; i < riders2.size(); j++) {
try {
assertEqual(rider, riders2.get(j), string, string2);
found = true;
break;
} catch (Exception e) {
continue;
}
}
if (!found) {
throw new RuntimeException("Annuity: IRider list not the same (match not found)!");
}
}
}
private void assertEqual(IRider clientRider, IRider resultRider, String string, String string2) throws Exception {
if (clientRider == null && resultRider == null)
return;
if (clientRider == null)
throw new RuntimeException("Annuity: IRider not the same (clientRider was null)! " +
string + " " + string2);
if (clientRider.getId().equals(resultRider.getId()))
return;
throw new RuntimeException("Annuity: IRider not the same (no match found)! " +
string + " " + string2);
}
private void assertPayorsEqual(List<IPayor> payors, List<IPayor> payors2, String string, String string2)
throws Exception {
if (payors == null && payors2 == null)
return;
if (payors == null)
throw new RuntimeException("Annuity: IPayor list not the same (payors was null)!");
if (payors.size() != payors2.size())
throw new RuntimeException("Annuity: IPayor list not the same (payors size not the same)!");
for (int i = 0; i < payors.size(); i++) {
IPayor payor = payors.get(i);
boolean found = false;
for (int j = 0; i < payors2.size(); j++) {
try {
assertEqual(payor, payors2.get(j), string, string2);
found = true;
break;
} catch (Exception e) {
continue;
}
}
if (!found) {
throw new RuntimeException("Annuity: IPayor list not the same (no match found)!");
}
}
}
private void verifyPayorValues(OpenJPAEntityManagerFactorySPI myEMF, IPayor payor) throws Exception {
IPayor results = null;
results = findPayorById(myEMF, Payor.class, payor.getId());
assertEqual(payor, results,
"Payor from Client is not equal to DB value.", "Mismacth was found.");
}
private IPayor findPayorById(OpenJPAEntityManagerFactorySPI myEMF, Class<Payor> class1, String id) {
EntityManager em = createEM(myEMF);
IPayor ip = em.find(class1, id);
closeEM(em);
return ip;
}
private void assertEqual(IPayor payor, IPayor results, String string, String string2) throws Exception {
if (payor == null && results == null)
return;
if (payor == null)
throw new RuntimeException("Annuity: IPayor not the same (payor was null)! " +
string + " " + string2);
if (payor.getId().equals(results.getId()))
return;
throw new RuntimeException("Annuity: IPayor not the same (no match found)! " +
string + " " + string2);
}
private IPayor createPayor(OpenJPAEntityManagerFactorySPI myEMF) {
EntityManager em = createEM(myEMF);
em.getTransaction().begin();
IPayor payor = new Payor();
payor.setId(getId());
payor.setName("Payor");
em.persist(payor);
em.getTransaction().commit();
closeEM(em);
return payor;
}
private void verifyAnnuityHolderValues(OpenJPAEntityManagerFactorySPI myEMF, IAnnuityHolder annuityHolder)
throws Exception {
IAnnuityHolder result = null;
result = findHolderById(myEMF, AnnuityHolder.class, annuityHolder.getId());
assertEqual(annuityHolder, result,
"Annuity Holder from Client is not equal to DB value.", "Mismacth was found.");
assertEqual(annuityHolder.getContact(), result.getContact(),
"Annuity Holder Contact from Client is not equal to DB value.", "Mismacth was found.");
}
private IAnnuityHolder findHolderById(OpenJPAEntityManagerFactorySPI myEMF, Class<AnnuityHolder> class1, String id)
{
EntityManager em = createEM(myEMF);
IAnnuityHolder result = em.find(class1, id);
closeEM(em);
return result;
}
private EntityManager createEM(OpenJPAEntityManagerFactorySPI myEMF) {
return myEMF.createEntityManager();
}
private void closeEM(EntityManager em) {
if (em != null) {
em.close();
em = null;
}
}
private void assertEqual(IAnnuityHolder annuityHolder, IAnnuityHolder results, String string, String string2)
throws Exception {
if (annuityHolder == null && results == null)
return;
if (annuityHolder == null)
throw new RuntimeException("Annuity: IAnnuityHolder not the same (annuityHolder was null)! " +
string + " " + string2);
if (annuityHolder.getId().equals(results.getId()))
return;
throw new RuntimeException("Annuity: IAnnuityHolder not the same (no match found)! " +
string + " " + string2);
}
private void assertEqual(IContact contact, IContact contact2, String string, String string2) throws Exception {
if (contact == null && contact2 == null)
return;
if (contact == null)
throw new RuntimeException("Annuity: Contacts not the same (contact was null)! " +
string + " " + string2);
if (contact.getId().equals(contact2.getId()))
return;
throw new RuntimeException("Annuity: Contacts not the same (no match found)! " +
string + " " + string2);
}
private IAnnuityHolder createAnnuityHolder(OpenJPAEntityManagerFactorySPI myEMF, IContact contact) {
EntityManager em = createEM(myEMF);
em.getTransaction().begin();
IAnnuityHolder annuityHolder = new AnnuityHolder();
annuityHolder.setCategory(AnnuityHolderCategory.METAL);
annuityHolder.setContact(contact);
annuityHolder.setId(getId());
annuityHolder.setFirstName("bob");
annuityHolder.setDateOfBirth(new Date());
annuityHolder.setGovernmentId("US");
annuityHolder.setLastName("dog");
annuityHolder.setTimeOfBirth(new Date());
em.persist(annuityHolder);
em.getTransaction().commit();
closeEM(em);
return annuityHolder;
}
private void verifyContactValues(OpenJPAEntityManagerFactorySPI myEMF, IContact contact) throws Exception {
// read the contact with id.
IContact results = null;
results = findContactById(myEMF, Contact.class, contact.getId());
assertEqual(contact, results,
"Contact from Client is not equal to DB value.", "Mismacth was found.");
}
private IContact findContactById(OpenJPAEntityManagerFactorySPI myEMF, Class<Contact> class1, String id) {
EntityManager em = createEM(myEMF);
IContact ic = em.find(class1, id);
closeEM(em);
return ic;
}
private IContact createContact(OpenJPAEntityManagerFactorySPI myEMF) {
EntityManager em = createEM(myEMF);
em.getTransaction().begin();
IContact contact = null;
contact = new Contact();
contact.setContactType(ContactType.BUSINESS);
contact.setId(getId());
contact.setEmail("here@there");
contact.setPhone("555-5555");
em.persist(contact);
em.getTransaction().commit();
closeEM(em);
return contact;
}
private String getId() {
UUID uid = UUID.randomUUID();
return uid.toString();
}
}

View File

@ -0,0 +1,78 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.openjpa.persistence.proxy.entities;
import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.Entity;
@Entity
@Embeddable
public class Address implements IAddress {
private static final long serialVersionUID = -2017682230659955349L;
private String line1;
private String line2;
private String city;
private String state;
private String zipCode;
private String country;
@Column(name="CITY")
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
@Column(name="COUNTRY")
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
@Column(name="LINE1")
public String getLine1() {
return line1;
}
public void setLine1(String line1) {
this.line1 = line1;
}
@Column(name="LINE2")
public String getLine2() {
return line2;
}
public void setLine2(String line2) {
this.line2 = line2;
}
@Column(name="STATE")
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
@Column(name="ZIP_CODE")
public String getZipCode() {
return zipCode;
}
public void setZipCode(String zipCode) {
this.zipCode = zipCode;
}
}

View File

@ -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.openjpa.persistence.proxy.entities;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.AttributeOverride;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
@SuppressWarnings("serial")
@Entity
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="DTYPE", discriminatorType=DiscriminatorType.STRING)
@DiscriminatorValue(value="ANNUITY")
@AttributeOverride(name="lastUpdateDate", column=@Column(name="LAST_UPDATE_TS"))
public class Annuity extends AnnuityPersistebleObject implements IAnnuity {
private Double lastPaidAmt;
private String AccountNumber;
private Double amount;
private String annuityHolderId;
private List<IPayout> payouts = new ArrayList<IPayout>();
private List<IRider> riders = new ArrayList<IRider>();
private List<IPayor> payors = new ArrayList<IPayor>();
public Annuity(){
}
@Column(name="LAST_PAID_AMT")
public Double getLastPaidAmt() {
return lastPaidAmt;
}
public void setLastPaidAmt(Double lastPaidAmt) {
this.lastPaidAmt = lastPaidAmt;
if (this.lastPaidAmt != null) {
DecimalFormat df = new DecimalFormat("#.##");
this.lastPaidAmt= new Double(df.format(lastPaidAmt));
}
}
@Column(name="ACCOUNT_NUMBER")
public String getAccountNumber() {
return AccountNumber;
}
public void setAccountNumber(String accountNumber) {
AccountNumber = accountNumber;
}
@Column(name="AMOUNT")
public Double getAmount() {
return amount;
}
public void setAmount(Double amount) {
this.amount = amount;
if (this.amount != null) {
DecimalFormat df = new DecimalFormat("#.##");
this.amount = new Double(df.format(amount));
}
}
@Column(name="FK_ANNUITY_HOLDER_ID")
public String getAnnuityHolderId() {
return this.annuityHolderId;
}
public void setAnnuityHolderId(String annuityHolderId) {
this.annuityHolderId = annuityHolderId;
}
@ManyToMany(targetEntity=Payor.class,
fetch=FetchType.EAGER)
@JoinTable(name="ANNUITY_PAYOR",
joinColumns={@JoinColumn(name="FK_ANNUITY_ID")},
inverseJoinColumns={@JoinColumn(name="FK_PAYOR_ID")})
public List<IPayor> getPayors() {
return this.payors;
}
public void setPayors(List<IPayor> payors) {
this.payors = payors;
}
@OneToMany(targetEntity=Payout.class,
mappedBy="annuity",
fetch=FetchType.EAGER)
public List<IPayout> getPayouts() {
return this.payouts;
}
public void setPayouts(List<IPayout> payouts) {
this.payouts = payouts;
}
@OneToMany(cascade={CascadeType.ALL},
targetEntity=Rider.class,
fetch=FetchType.EAGER)
@JoinTable(name="ANNUITY_RIDER",
joinColumns={@JoinColumn(name="FK_ANNUITY_ID")},
inverseJoinColumns={@JoinColumn(name="FK_RIDER_ID")})
public List<IRider> getRiders() {
return this.riders;
}
public void setRiders(List<IRider> riders) {
this.riders = riders;
}
}

View File

@ -0,0 +1,48 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.openjpa.persistence.proxy.entities;
import javax.persistence.AttributeOverride;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;
@Entity
@PrimaryKeyJoinColumn(name="ID")
@Table(name="ANNUITY_HOLDER")
@AttributeOverride(name="lastUpdateDate", column=@Column(name="LAST_UPDATE_TS"))
public class AnnuityHolder extends Person implements IAnnuityHolder{
private static final long serialVersionUID = 3307367871936336517L;
private AnnuityHolderCategory category;
@Column(name="CATEGORY")
@Enumerated(EnumType.ORDINAL)
public AnnuityHolderCategory getCategory() {
return this.category;
}
public void setCategory(AnnuityHolderCategory category) {
this.category = category;
}
}

View File

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

View File

@ -0,0 +1,78 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.openjpa.persistence.proxy.entities;
import java.util.Date;
import javax.persistence.MappedSuperclass;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
import javax.persistence.Transient;
import javax.persistence.Version;
@MappedSuperclass
public class AnnuityPersistebleObject implements JPAPersisteble {
private static final long serialVersionUID = -1752164352355128830L;
private String id;
private Date lastUpdateDate;
private Parameterizable<String, String> config = new StringParameterizable();
private int version;
@Version
public int getVersion() {
return version;
}
public void setVersion(int version) {
this.version = version;
}
@javax.persistence.Id
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public Date getLastUpdateDate() {
return lastUpdateDate;
}
public void setLastUpdateDate(Date lastUpdateDate) {
this.lastUpdateDate = lastUpdateDate;
}
@Transient
public Parameterizable<String, String> getConfiguration() {
return this.config;
}
@Transient
public void setConfiguration(Parameterizable<String, String> config) {
this.config = config;
}
@SuppressWarnings("unused")
@PrePersist
@PreUpdate
private void fixLastUpdateDate(){
setLastUpdateDate(new Date());
}
}

View File

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

View File

@ -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.openjpa.persistence.proxy.entities;
import java.io.Serializable;
public interface Configrable<K, V> extends Serializable{
public Parameterizable<K, V> getConfiguration();
public void setConfiguration(Parameterizable<K, V> config);
}

View File

@ -0,0 +1,87 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.openjpa.persistence.proxy.entities;
import javax.persistence.AttributeOverride;
import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Table;
import javax.persistence.Transient;
@Entity
@Table(name="CONTACT")
@AttributeOverride(name="lastUpdateDate", column=@Column(name="LAST_UPDATE_TS"))
public class Contact extends AnnuityPersistebleObject implements IContact {
private static final long serialVersionUID = 4015672780551057807L;
private Address theAddress;
private String email;
private String phone;
private ContactType contactType;
@Transient
public IAddress getAddress() {
return (IAddress) this.getTheAddress();
}
public void setAddress(IAddress address) {
if (address instanceof Address){
this.setTheAddress((Address)address);
}else if(address == null) {
this.setTheAddress(null);
}
else{
throw new ClassCastException("Invalid Implementaion of IAddress. " +
"Class must be instance of com.ibm.wssvt.acme.annuity.common.bean.jpa.Address");
}
}
@Embedded
private Address getTheAddress() {
return theAddress;
}
private void setTheAddress(Address address) {
this.theAddress = address;
}
@Column(name="EMAIL")
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
@Column(name="PHONE")
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
@Column(name="TYPE")
@Enumerated(EnumType.STRING)
public ContactType getContactType() {
return contactType;
}
public void setContactType(ContactType contactType) {
this.contactType = contactType;
}
}

View File

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

View File

@ -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.openjpa.persistence.proxy.entities;
import java.text.DecimalFormat;
import javax.persistence.Column;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
@Entity
@DiscriminatorValue(value = "EQUITY")
public class EquityAnnuity extends Annuity implements IEquityAnnuity {
private static final long serialVersionUID = -7227462924769151013L;
private String fundNames;
private Double indexRate;
@Column(name="FUND_NAMES")
public String getFundNames() {
return fundNames;
}
public void setFundNames(String fundNames) {
this.fundNames = fundNames;
}
@Column(name="INDEX_RATE")
public Double getIndexRate() {
return indexRate;
}
public void setIndexRate(Double indexRate) {
this.indexRate = indexRate;
if (this.indexRate != null) {
DecimalFormat df = new DecimalFormat("#.##");
this.indexRate= new Double(df.format(indexRate));
}
}
}

View File

@ -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.openjpa.persistence.proxy.entities;
import java.text.DecimalFormat;
import javax.persistence.Column;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
@Entity
@DiscriminatorValue(value = "FIXED")
public class FixedAnnuity extends Annuity implements IFixedAnnuity {
private static final long serialVersionUID = 1527245835840605452L;
private Double rate;
@Column(name="FIXED_RATE")
public Double getRate() {
return rate;
}
public void setRate(Double rate) {
this.rate = rate;
if (this.rate != null) {
DecimalFormat df = new DecimalFormat("#.##");
this.rate= new Double(df.format(rate));
}
}
}

View File

@ -0,0 +1,49 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.openjpa.persistence.proxy.entities;
import java.io.Serializable;
public interface IAddress extends Serializable {
public String getCity();
public void setCity(String city);
public String getCountry();
public void setCountry(String country);
public String getLine1();
public void setLine1(String line1);
public String getLine2();
public void setLine2(String line2);
public String getState();
public void setState(String state);
public String getZipCode();
public void setZipCode(String zipCode);
}

View File

@ -0,0 +1,49 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.openjpa.persistence.proxy.entities;
import java.util.List;
public interface IAnnuity extends IAnnuityObject {
public abstract Double getLastPaidAmt();
public abstract void setLastPaidAmt(Double lastPaidAmt);
public abstract String getAccountNumber();
public abstract void setAccountNumber(String accountNumber);
public abstract Double getAmount();
public abstract void setAmount(Double amount);
public abstract List<IPayout> getPayouts();
public abstract void setPayouts(List<IPayout> payout);
public abstract List<IRider> getRiders();
public abstract void setRiders(List<IRider> riders);
public abstract String getAnnuityHolderId();
public abstract void setAnnuityHolderId(String annuityHolderId);
public abstract List<IPayor> getPayors();
public abstract void setPayors(List<IPayor> payors);
}

View File

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

View File

@ -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.openjpa.persistence.proxy.entities;
import java.util.Date;
public interface IAnnuityObject extends Identifiable {
public void setLastUpdateDate(Date date);
public Date getLastUpdateDate();
}

View File

@ -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.openjpa.persistence.proxy.entities;
public interface IContact extends IAnnuityObject {
public IAddress getAddress();
public void setAddress(IAddress address);
public String getEmail();
public void setEmail(String email);
public String getPhone();
public void setPhone(String phone);
public ContactType getContactType();
public void setContactType(ContactType type);
}

View File

@ -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.openjpa.persistence.proxy.entities;
public interface IEquityAnnuity extends IAnnuity{
public String getFundNames();
public void setFundNames(String fundNames);
public Double getIndexRate();
public void setIndexRate(Double indexRate);
}

View File

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

View File

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

View File

@ -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.openjpa.persistence.proxy.entities;
import java.math.BigDecimal;
import java.util.Calendar;
public interface IPayout extends IAnnuityObject{
public void setTaxableAmount(BigDecimal taxableAmount);
public BigDecimal getTaxableAmount();
public void setStartDate(Calendar startDate);
public Calendar getStartDate();
public void setEndDate(Calendar payoutEndDate);
public Calendar getEndDate();
public IAnnuity getAnnuity();
public void setAnnuity(IAnnuity annuity);
}

View File

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

View File

@ -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.openjpa.persistence.proxy.entities;
import java.util.Date;
public interface IPerson extends IAnnuityObject {
public Date getDateOfBirth();
public void setDateOfBirth(Date dateOfBirth);
public String getFirstName();
public void setFirstName(String firstName);
public String getGovernmentId();
public void setGovernmentId(String governmentId);
public String getLastName();
public void setLastName(String lastName);
public Byte[] getPicture();
public void setPicture(Byte[] picture);
public Date getTimeOfBirth();
public void setTimeOfBirth(Date timeOfBirth);
public IContact getContact();
public void setContact(IContact contact);
}

View File

@ -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.openjpa.persistence.proxy.entities;
import java.util.Date;
public interface IRider extends IAnnuityObject {
public Date getEffectiveDate();
public void setEffectiveDate(Date date);
public String getRule();
public void setRule(String rule);
public RiderType getType();
public void setType(RiderType type);
}

View File

@ -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.openjpa.persistence.proxy.entities;
import java.io.Serializable;
public interface Identifiable extends Configrable<String, String>, Serializable{
public String getId();
public void setId(String id);
}

View File

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

View File

@ -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.openjpa.persistence.proxy.entities;
import java.io.Serializable;
import java.util.Map;
public interface Parameterizable <K,V> extends Serializable{
public void addParameter(K key, V value);
public void removeParameter(K key);
public void clearAllParameters();
public Map<K, V> getParameters();
public V getParameterValue(K key);
public void addAllParams(Map<K,V> newParams);
}

View File

@ -0,0 +1,40 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.openjpa.persistence.proxy.entities;
import javax.persistence.AttributeOverride;
import javax.persistence.Column;
import javax.persistence.Entity;
@Entity
@AttributeOverride(name="lastUpdateDate", column=@Column(name="LAST_UPDATE_TS"))
public class Payor extends AnnuityPersistebleObject implements IPayor {
private static final long serialVersionUID = 3462390122289537362L;
private String name;
@Column(name="NAME")
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
}

View File

@ -0,0 +1,81 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.openjpa.persistence.proxy.entities;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.Calendar;
import javax.persistence.AttributeOverride;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
@Entity
@AttributeOverride(name="lastUpdateDate", column=@Column(name="LAST_UPDATE_TS"))
public class Payout extends AnnuityPersistebleObject implements IPayout {
private static final long serialVersionUID = 2837981324963617180L;
private BigDecimal taxableAmount;
private Calendar startDate;
private Calendar endDate;
private IAnnuity annuity;
@Column(name="TAXABLE_AMOUNT")
public BigDecimal getTaxableAmount() {
return this.taxableAmount;
}
public void setTaxableAmount(BigDecimal payoutTaxableAmt) {
this.taxableAmount = payoutTaxableAmt;
if (payoutTaxableAmt != null) {
DecimalFormat df = new DecimalFormat("#.##");
this.taxableAmount = new BigDecimal(df.format(payoutTaxableAmt));
}
}
@Column(name="START_DATE")
public Calendar getStartDate() {
return startDate;
}
public void setStartDate(Calendar startDate) {
this.startDate = startDate;
}
@Column(name="END_DATE")
public Calendar getEndDate() {
return endDate;
}
public void setEndDate(Calendar payoutEndDate) {
this.endDate = payoutEndDate;
}
@ManyToOne(targetEntity=Annuity.class,
fetch=FetchType.EAGER)
@JoinColumn(name="FK_ANNUITY_ID")
public IAnnuity getAnnuity() {
return this.annuity;
}
public void setAnnuity(IAnnuity annuity) {
this.annuity = annuity;
}
}

View File

@ -0,0 +1,107 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.openjpa.persistence.proxy.entities;
import java.util.Date;
import javax.persistence.AttributeOverride;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.OneToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
@Entity
@Inheritance(strategy=InheritanceType.JOINED)
@AttributeOverride(name="lastUpdateDate", column=@Column(name="LAST_UPDATE_TS"))
public class Person extends AnnuityPersistebleObject implements IPerson {
private static final long serialVersionUID = 6583119146735692154L;
private String firstName;
private String lastName;
private String governmentId;
private Date dateOfBirth;
private Date timeOfBirth;
private Byte[] picture;
private IContact contact;
@Column(name="DATE_OF_BIRTH")
@Temporal(TemporalType.DATE)
public Date getDateOfBirth() {
return dateOfBirth;
}
public void setDateOfBirth(Date dateOfBirth) {
this.dateOfBirth = dateOfBirth;
}
@Column(name="FIRST_NAME")
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
@Column(name="GOVERNMENT_ID")
public String getGovernmentId() {
return governmentId;
}
public void setGovernmentId(String governmentId) {
this.governmentId = governmentId;
}
@Column(name="LAST_NAME")
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
@Column(name="PICTURE")
@Lob
public Byte[] getPicture() {
return picture;
}
public void setPicture(Byte[] picture) {
this.picture = picture;
}
@Column(name="TIME_OF_BIRTH")
@Temporal(TemporalType.TIME)
public Date getTimeOfBirth() {
return timeOfBirth;
}
public void setTimeOfBirth(Date timeOfBirth) {
this.timeOfBirth = timeOfBirth;
}
@OneToOne(
cascade={CascadeType.REFRESH, CascadeType.MERGE},
targetEntity=Contact.class)
@JoinColumn(name="FK_CONTACT_ID")
public IContact getContact() {
return this.contact;
}
public void setContact(IContact contact) {
this.contact = contact;
}
}

View File

@ -0,0 +1,61 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.openjpa.persistence.proxy.entities;
import java.util.Date;
import javax.persistence.AttributeOverride;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
@Entity
@AttributeOverride(name="lastUpdateDate", column=@Column(name="LAST_UPDATE_TS"))
public class Rider extends AnnuityPersistebleObject implements IRider {
private static final long serialVersionUID = 2088116709551706187L;
private String rule;
private Date effectiveDate;
private RiderType type;
@Column(name="EFFECTIVE_DATE")
public Date getEffectiveDate() {
return effectiveDate;
}
public void setEffectiveDate(Date effectiveDate) {
this.effectiveDate = effectiveDate;
}
public String getRule() {
return rule;
}
public void setRule(String rule) {
this.rule = rule;
}
@Enumerated(EnumType.STRING)
public RiderType getType() {
return type;
}
public void setType(RiderType type) {
this.type = type;
}
}

View File

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

View File

@ -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.openjpa.persistence.proxy.entities;
import java.util.HashMap;
import java.util.Map;
public class StringParameterizable implements Parameterizable<String, String> {
private static final long serialVersionUID = -4289064323865338447L;
private Map<String, String> params = new HashMap<String, String>();
public void addParameter(String key, String value) {
this.params.put(key, value);
}
public Map<String, String> getParameters() {
return this.params;
}
public void removeParameter(String key) {
this.params.remove(key);
}
public void clearAllParameters() {
this.params.clear();
}
public String getParameterValue(String key) {
return this.params.get(key);
}
public void addAllParams(Map<String, String> newParams) {
if (newParams != null) {
params.putAll(newParams);
}
}
}

View File

@ -341,4 +341,28 @@
</properties>
</persistence-unit>
<persistence-unit name="TestDetachMerge">
<class>org.apache.openjpa.persistence.proxy.entities.Address</class>
<class>org.apache.openjpa.persistence.proxy.entities.Annuity</class>
<class>org.apache.openjpa.persistence.proxy.entities.AnnuityHolder</class>
<class>org.apache.openjpa.persistence.proxy.entities.AnnuityPersistebleObject</class>
<class>org.apache.openjpa.persistence.proxy.entities.Contact</class>
<class>org.apache.openjpa.persistence.proxy.entities.EquityAnnuity</class>
<class>org.apache.openjpa.persistence.proxy.entities.FixedAnnuity</class>
<class>org.apache.openjpa.persistence.proxy.entities.Payor</class>
<class>org.apache.openjpa.persistence.proxy.entities.Payout</class>
<class>org.apache.openjpa.persistence.proxy.entities.Person</class>
<class>org.apache.openjpa.persistence.proxy.entities.Rider</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="openjpa.jdbc.SynchronizeMappings"
value="buildSchema(ForeignKeys=true)"/>
<!--
<property name="openjpa.DetachState"
value="fgs(DetachedStateField=true)" />
<property name="openjpa.jdbc.Schema" value="EJB30" />
-->
</properties>
</persistence-unit>
</persistence>

View File

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="1.0"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="Annuity1Compat">
<class>org.apache.openjpa.persistence.proxy.entities.Address</class>
<class>org.apache.openjpa.persistence.proxy.entities.Annuity</class>
<class>org.apache.openjpa.persistence.proxy.entities.AnnuityHolder</class>
<class>org.apache.openjpa.persistence.proxy.entities.AnnuityPersistebleObject</class>
<class>org.apache.openjpa.persistence.proxy.entities.Contact</class>
<class>org.apache.openjpa.persistence.proxy.entities.EquityAnnuity</class>
<class>org.apache.openjpa.persistence.proxy.entities.FixedAnnuity</class>
<class>org.apache.openjpa.persistence.proxy.entities.Payor</class>
<class>org.apache.openjpa.persistence.proxy.entities.Payout</class>
<class>org.apache.openjpa.persistence.proxy.entities.Person</class>
<class>org.apache.openjpa.persistence.proxy.entities.Rider</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="openjpa.DetachState" value="fgs(DetachedStateField=true)" />
<!-- <property name="openjpa.jdbc.Schema" value="EJB30"/> -->
<property name="openjpa.jdbc.SynchronizeMappings"
value="buildSchema(ForeignKeys=true)"/>
</properties>
</persistence-unit>
</persistence>

View File

@ -0,0 +1,102 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="2.0"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<!--
This is the original PU from 1.0, but running as a 2.0 app
-->
<persistence-unit name="Annuity2Fail">
<class>org.apache.openjpa.persistence.proxy.entities.Address</class>
<class>org.apache.openjpa.persistence.proxy.entities.Annuity</class>
<class>org.apache.openjpa.persistence.proxy.entities.AnnuityHolder</class>
<class>org.apache.openjpa.persistence.proxy.entities.AnnuityPersistebleObject</class>
<class>org.apache.openjpa.persistence.proxy.entities.Contact</class>
<class>org.apache.openjpa.persistence.proxy.entities.EquityAnnuity</class>
<class>org.apache.openjpa.persistence.proxy.entities.FixedAnnuity</class>
<class>org.apache.openjpa.persistence.proxy.entities.Payor</class>
<class>org.apache.openjpa.persistence.proxy.entities.Payout</class>
<class>org.apache.openjpa.persistence.proxy.entities.Person</class>
<class>org.apache.openjpa.persistence.proxy.entities.Rider</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="openjpa.DetachState" value="fgs(DetachedStateField=true)" />
<!-- <property name="openjpa.jdbc.Schema" value="EJB30"/> -->
<property name="openjpa.jdbc.SynchronizeMappings"
value="buildSchema(ForeignKeys=true)"/>
</properties>
</persistence-unit>
<!--
This is the original PU from 1.0, but with the DetachedStateField
override removed, which will cause a transient one to be used
and the tests will pass.
-->
<persistence-unit name="Annuity2New">
<class>org.apache.openjpa.persistence.proxy.entities.Address</class>
<class>org.apache.openjpa.persistence.proxy.entities.Annuity</class>
<class>org.apache.openjpa.persistence.proxy.entities.AnnuityHolder</class>
<class>org.apache.openjpa.persistence.proxy.entities.AnnuityPersistebleObject</class>
<class>org.apache.openjpa.persistence.proxy.entities.Contact</class>
<class>org.apache.openjpa.persistence.proxy.entities.EquityAnnuity</class>
<class>org.apache.openjpa.persistence.proxy.entities.FixedAnnuity</class>
<class>org.apache.openjpa.persistence.proxy.entities.Payor</class>
<class>org.apache.openjpa.persistence.proxy.entities.Payout</class>
<class>org.apache.openjpa.persistence.proxy.entities.Person</class>
<class>org.apache.openjpa.persistence.proxy.entities.Rider</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<!-- <property name="openjpa.DetachState" value="fgs(DetachedStateField=true)" /> -->
<!-- <property name="openjpa.jdbc.Schema" value="EJB30"/> -->
<property name="openjpa.jdbc.SynchronizeMappings"
value="buildSchema(ForeignKeys=true)"/>
</properties>
</persistence-unit>
<!--
This is the original PU from 1.0, but running as a 2.0 app
with the new Compatibility flag set to use the old 1.0 behavior,
so the tests will pass.
-->
<persistence-unit name="Annuity2Compat">
<class>org.apache.openjpa.persistence.proxy.entities.Address</class>
<class>org.apache.openjpa.persistence.proxy.entities.Annuity</class>
<class>org.apache.openjpa.persistence.proxy.entities.AnnuityHolder</class>
<class>org.apache.openjpa.persistence.proxy.entities.AnnuityPersistebleObject</class>
<class>org.apache.openjpa.persistence.proxy.entities.Contact</class>
<class>org.apache.openjpa.persistence.proxy.entities.EquityAnnuity</class>
<class>org.apache.openjpa.persistence.proxy.entities.FixedAnnuity</class>
<class>org.apache.openjpa.persistence.proxy.entities.Payor</class>
<class>org.apache.openjpa.persistence.proxy.entities.Payout</class>
<class>org.apache.openjpa.persistence.proxy.entities.Person</class>
<class>org.apache.openjpa.persistence.proxy.entities.Rider</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<!-- <property name="openjpa.Compatibility.xxxxx" value="true)" /> -->
<property name="openjpa.DetachState" value="fgs(DetachedStateField=true)" />
<!-- <property name="openjpa.jdbc.Schema" value="EJB30"/> -->
<property name="openjpa.jdbc.SynchronizeMappings"
value="buildSchema(ForeignKeys=true)"/>
</properties>
</persistence-unit>
</persistence>