diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/TestDetachMerge.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/TestDetachMerge.java new file mode 100644 index 000000000..8956e8b8d --- /dev/null +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/TestDetachMerge.java @@ -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 class1, String id) { + EntityManager em = createEM(myEMF); + IAnnuity ann = em.find(class1, id); + closeEM(em); + return ann; + } + + private void assertEqual(List payouts, List 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 riders, List 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 payors, List 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 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 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 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(); + } + +} diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/Address.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/Address.java new file mode 100644 index 000000000..adc486f8f --- /dev/null +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/Address.java @@ -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; + } +} diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/Annuity.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/Annuity.java new file mode 100644 index 000000000..96816fdbc --- /dev/null +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/Annuity.java @@ -0,0 +1,140 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.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 payouts = new ArrayList(); + private List riders = new ArrayList(); + private List payors = new ArrayList(); + + 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 getPayors() { + return this.payors; + } + public void setPayors(List payors) { + this.payors = payors; + + } + + @OneToMany(targetEntity=Payout.class, + mappedBy="annuity", + fetch=FetchType.EAGER) + public List getPayouts() { + return this.payouts; + } + public void setPayouts(List 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 getRiders() { + return this.riders; + } + public void setRiders(List riders) { + this.riders = riders; + } + + + + +} diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/AnnuityHolder.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/AnnuityHolder.java new file mode 100644 index 000000000..80e5e8b1f --- /dev/null +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/AnnuityHolder.java @@ -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; + } + + +} diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/AnnuityHolderCategory.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/AnnuityHolderCategory.java new file mode 100644 index 000000000..d2e4d2d0a --- /dev/null +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/AnnuityHolderCategory.java @@ -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; +} diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/AnnuityPersistebleObject.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/AnnuityPersistebleObject.java new file mode 100644 index 000000000..26793640c --- /dev/null +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/AnnuityPersistebleObject.java @@ -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 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 getConfiguration() { + return this.config; + } + @Transient + public void setConfiguration(Parameterizable config) { + this.config = config; + } + + @SuppressWarnings("unused") + @PrePersist + @PreUpdate + private void fixLastUpdateDate(){ + setLastUpdateDate(new Date()); + } +} diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/AnnuityType.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/AnnuityType.java new file mode 100644 index 000000000..a86719cfa --- /dev/null +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/AnnuityType.java @@ -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; +} diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/Configrable.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/Configrable.java new file mode 100644 index 000000000..044351fcc --- /dev/null +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/Configrable.java @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openjpa.persistence.proxy.entities; + +import java.io.Serializable; + +public interface Configrable extends Serializable{ + public Parameterizable getConfiguration(); + public void setConfiguration(Parameterizable config); +} diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/Contact.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/Contact.java new file mode 100644 index 000000000..7a0517fe8 --- /dev/null +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/Contact.java @@ -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; + } + +} diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/ContactType.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/ContactType.java new file mode 100644 index 000000000..4735749df --- /dev/null +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/ContactType.java @@ -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; +} diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/EquityAnnuity.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/EquityAnnuity.java new file mode 100644 index 000000000..453100aa2 --- /dev/null +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/EquityAnnuity.java @@ -0,0 +1,59 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.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)); + } + } + +} diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/FixedAnnuity.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/FixedAnnuity.java new file mode 100644 index 000000000..4ba982e75 --- /dev/null +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/FixedAnnuity.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.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)); + } + } +} diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/IAddress.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/IAddress.java new file mode 100644 index 000000000..49517c1a7 --- /dev/null +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/IAddress.java @@ -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); + +} diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/IAnnuity.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/IAnnuity.java new file mode 100644 index 000000000..36d7d935e --- /dev/null +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/IAnnuity.java @@ -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 getPayouts(); + public abstract void setPayouts(List payout); + + public abstract List getRiders(); + public abstract void setRiders(List riders); + + public abstract String getAnnuityHolderId(); + public abstract void setAnnuityHolderId(String annuityHolderId); + + public abstract List getPayors(); + public abstract void setPayors(List payors); + +} diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/IAnnuityHolder.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/IAnnuityHolder.java new file mode 100644 index 000000000..66bc21c5b --- /dev/null +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/IAnnuityHolder.java @@ -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); + + +} diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/IAnnuityObject.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/IAnnuityObject.java new file mode 100644 index 000000000..21f4b0ff5 --- /dev/null +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/IAnnuityObject.java @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openjpa.persistence.proxy.entities; + +import java.util.Date; + +public interface IAnnuityObject extends Identifiable { + public void setLastUpdateDate(Date date); + public Date getLastUpdateDate(); +} diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/IContact.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/IContact.java new file mode 100644 index 000000000..c4a30475b --- /dev/null +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/IContact.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.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); + +} diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/IEquityAnnuity.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/IEquityAnnuity.java new file mode 100644 index 000000000..35962ec05 --- /dev/null +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/IEquityAnnuity.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.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); + +} diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/IFixedAnnuity.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/IFixedAnnuity.java new file mode 100644 index 000000000..29e4f01a1 --- /dev/null +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/IFixedAnnuity.java @@ -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); + +} diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/IPayor.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/IPayor.java new file mode 100644 index 000000000..3d68075e6 --- /dev/null +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/IPayor.java @@ -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); + +} diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/IPayout.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/IPayout.java new file mode 100644 index 000000000..4eeb90cc8 --- /dev/null +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/IPayout.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.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); + +} diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/IPersisteble.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/IPersisteble.java new file mode 100644 index 000000000..6006ee909 --- /dev/null +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/IPersisteble.java @@ -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 { + +} diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/IPerson.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/IPerson.java new file mode 100644 index 000000000..7c07fd63d --- /dev/null +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/IPerson.java @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.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); + +} diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/IRider.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/IRider.java new file mode 100644 index 000000000..4342afb47 --- /dev/null +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/IRider.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.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); + +} diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/Identifiable.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/Identifiable.java new file mode 100644 index 000000000..54742671f --- /dev/null +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/Identifiable.java @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openjpa.persistence.proxy.entities; + +import java.io.Serializable; + +public interface Identifiable extends Configrable, Serializable{ + public String getId(); + public void setId(String id); +} diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/JPAPersisteble.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/JPAPersisteble.java new file mode 100644 index 000000000..4e9ad3009 --- /dev/null +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/JPAPersisteble.java @@ -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{ + +} diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/Parameterizable.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/Parameterizable.java new file mode 100644 index 000000000..e2ddee602 --- /dev/null +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/Parameterizable.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openjpa.persistence.proxy.entities; + +import java.io.Serializable; +import java.util.Map; + +public interface Parameterizable extends Serializable{ + public void addParameter(K key, V value); + public void removeParameter(K key); + public void clearAllParameters(); + public Map getParameters(); + public V getParameterValue(K key); + public void addAllParams(Map newParams); +} diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/Payor.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/Payor.java new file mode 100644 index 000000000..7cebeee90 --- /dev/null +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/Payor.java @@ -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; + } + +} diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/Payout.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/Payout.java new file mode 100644 index 000000000..29ac27a13 --- /dev/null +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/Payout.java @@ -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; + + } + +} diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/Person.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/Person.java new file mode 100644 index 000000000..b1e874072 --- /dev/null +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/Person.java @@ -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; + } + +} diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/Rider.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/Rider.java new file mode 100644 index 000000000..e97b8c6b4 --- /dev/null +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/Rider.java @@ -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; + } + + +} diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/RiderType.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/RiderType.java new file mode 100644 index 000000000..7ed149648 --- /dev/null +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/RiderType.java @@ -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; +} diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/StringParameterizable.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/StringParameterizable.java new file mode 100644 index 000000000..e890a6b6d --- /dev/null +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/proxy/entities/StringParameterizable.java @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.openjpa.persistence.proxy.entities; + +import java.util.HashMap; +import java.util.Map; + +public class StringParameterizable implements Parameterizable { + private static final long serialVersionUID = -4289064323865338447L; + private Map params = new HashMap(); + + public void addParameter(String key, String value) { + this.params.put(key, value); + } + + public Map 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 newParams) { + if (newParams != null) { + params.putAll(newParams); + } + } +} diff --git a/openjpa-persistence-jdbc/src/test/resources/META-INF/persistence.xml b/openjpa-persistence-jdbc/src/test/resources/META-INF/persistence.xml index 6231182dd..7087c58f3 100644 --- a/openjpa-persistence-jdbc/src/test/resources/META-INF/persistence.xml +++ b/openjpa-persistence-jdbc/src/test/resources/META-INF/persistence.xml @@ -341,4 +341,28 @@ + + org.apache.openjpa.persistence.proxy.entities.Address + org.apache.openjpa.persistence.proxy.entities.Annuity + org.apache.openjpa.persistence.proxy.entities.AnnuityHolder + org.apache.openjpa.persistence.proxy.entities.AnnuityPersistebleObject + org.apache.openjpa.persistence.proxy.entities.Contact + org.apache.openjpa.persistence.proxy.entities.EquityAnnuity + org.apache.openjpa.persistence.proxy.entities.FixedAnnuity + org.apache.openjpa.persistence.proxy.entities.Payor + org.apache.openjpa.persistence.proxy.entities.Payout + org.apache.openjpa.persistence.proxy.entities.Person + org.apache.openjpa.persistence.proxy.entities.Rider + true + + + + + + diff --git a/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/proxy/persistence1.xml b/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/proxy/persistence1.xml new file mode 100644 index 000000000..b84c71627 --- /dev/null +++ b/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/proxy/persistence1.xml @@ -0,0 +1,46 @@ + + + + + + org.apache.openjpa.persistence.proxy.entities.Address + org.apache.openjpa.persistence.proxy.entities.Annuity + org.apache.openjpa.persistence.proxy.entities.AnnuityHolder + org.apache.openjpa.persistence.proxy.entities.AnnuityPersistebleObject + org.apache.openjpa.persistence.proxy.entities.Contact + org.apache.openjpa.persistence.proxy.entities.EquityAnnuity + org.apache.openjpa.persistence.proxy.entities.FixedAnnuity + org.apache.openjpa.persistence.proxy.entities.Payor + org.apache.openjpa.persistence.proxy.entities.Payout + org.apache.openjpa.persistence.proxy.entities.Person + org.apache.openjpa.persistence.proxy.entities.Rider + true + + + + + + + diff --git a/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/proxy/persistence2.xml b/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/proxy/persistence2.xml new file mode 100644 index 000000000..f564e6d66 --- /dev/null +++ b/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/proxy/persistence2.xml @@ -0,0 +1,102 @@ + + + + + + + org.apache.openjpa.persistence.proxy.entities.Address + org.apache.openjpa.persistence.proxy.entities.Annuity + org.apache.openjpa.persistence.proxy.entities.AnnuityHolder + org.apache.openjpa.persistence.proxy.entities.AnnuityPersistebleObject + org.apache.openjpa.persistence.proxy.entities.Contact + org.apache.openjpa.persistence.proxy.entities.EquityAnnuity + org.apache.openjpa.persistence.proxy.entities.FixedAnnuity + org.apache.openjpa.persistence.proxy.entities.Payor + org.apache.openjpa.persistence.proxy.entities.Payout + org.apache.openjpa.persistence.proxy.entities.Person + org.apache.openjpa.persistence.proxy.entities.Rider + true + + + + + + + + + + org.apache.openjpa.persistence.proxy.entities.Address + org.apache.openjpa.persistence.proxy.entities.Annuity + org.apache.openjpa.persistence.proxy.entities.AnnuityHolder + org.apache.openjpa.persistence.proxy.entities.AnnuityPersistebleObject + org.apache.openjpa.persistence.proxy.entities.Contact + org.apache.openjpa.persistence.proxy.entities.EquityAnnuity + org.apache.openjpa.persistence.proxy.entities.FixedAnnuity + org.apache.openjpa.persistence.proxy.entities.Payor + org.apache.openjpa.persistence.proxy.entities.Payout + org.apache.openjpa.persistence.proxy.entities.Person + org.apache.openjpa.persistence.proxy.entities.Rider + true + + + + + + + + + + org.apache.openjpa.persistence.proxy.entities.Address + org.apache.openjpa.persistence.proxy.entities.Annuity + org.apache.openjpa.persistence.proxy.entities.AnnuityHolder + org.apache.openjpa.persistence.proxy.entities.AnnuityPersistebleObject + org.apache.openjpa.persistence.proxy.entities.Contact + org.apache.openjpa.persistence.proxy.entities.EquityAnnuity + org.apache.openjpa.persistence.proxy.entities.FixedAnnuity + org.apache.openjpa.persistence.proxy.entities.Payor + org.apache.openjpa.persistence.proxy.entities.Payout + org.apache.openjpa.persistence.proxy.entities.Person + org.apache.openjpa.persistence.proxy.entities.Rider + true + + + + + + + +