Package org.apache.openjpa.persistence.arrays

Source Code of org.apache.openjpa.persistence.arrays.TestXMLExceptionEntity

/*
* 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.arrays;

import java.util.ArrayList;

import javax.persistence.EntityManager;

import org.apache.openjpa.persistence.arrays.model.XMLExceptionEntity;
import org.apache.openjpa.persistence.test.SingleEMFTestCase;

public class TestXMLExceptionEntity extends SingleEMFTestCase {
   
    @Override
    protected String getPersistenceUnitName() {
        return "arrays";
    }
   
    public void testExceptionArrayAsLob() {
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
       
        XMLExceptionEntity e = new XMLExceptionEntity();
        e.setId(1);
        em.persist(e);
        e.setExceptions(new ArrayList<Exception>());
        e.getExceptions().add(new Exception("Exception 1"));
        e.getExceptions().add(new Exception("Exception 2"));
        em.getTransaction().commit();
       
        em.clear();
        e = em.find(XMLExceptionEntity.class, 1);
       
        assertNotNull(e);
        assertNotNull(e.getExceptions());
        assertEquals(2, e.getExceptions().size());
        // we don't really care about ordering for this example.
       
        em.getTransaction().begin();
        em.remove(e);
        em.getTransaction().commit();
       
        em.close();
    }

}
TOP

Related Classes of org.apache.openjpa.persistence.arrays.TestXMLExceptionEntity

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.