Search in sources :

Example 1 with AReallyObnoxiouslyLongWindedNamedObject

use of org.datanucleus.samples.rdbms.datastore.AReallyObnoxiouslyLongWindedNamedObject in project tests by datanucleus.

the class SchemaTest method testClassWithLongName.

/**
 * Test for a class with a very long name that exceeds the maximum length for the schema.
 * Checks that the name of the table in the schema is truncated (or rather that it doesnt throw an exception, i.e auto-truncates it).
 * @throws Exception
 */
public void testClassWithLongName() throws Exception {
    addClassesToSchema(new Class[] { AReallyObnoxiouslyLongWindedNamedObject.class });
    PersistenceManager pm = pmf.getPersistenceManager();
    Transaction tx = pm.currentTransaction();
    try {
        tx.begin();
        AReallyObnoxiouslyLongWindedNamedObject obj = new AReallyObnoxiouslyLongWindedNamedObject("Test");
        pm.makePersistent(obj);
        pm.flush();
        pm.getExtent(AReallyObnoxiouslyLongWindedNamedObject.class);
        tx.rollback();
    } catch (Exception e) {
        LOG.error(e);
        fail(e.toString());
    } finally {
        if (tx.isActive()) {
            tx.rollback();
        }
        pm.close();
    }
}
Also used : Transaction(javax.jdo.Transaction) JDOPersistenceManager(org.datanucleus.api.jdo.JDOPersistenceManager) PersistenceManager(javax.jdo.PersistenceManager) AReallyObnoxiouslyLongWindedNamedObject(org.datanucleus.samples.rdbms.datastore.AReallyObnoxiouslyLongWindedNamedObject) JDOUserException(javax.jdo.JDOUserException) JDOFatalUserException(javax.jdo.JDOFatalUserException) SQLException(java.sql.SQLException) JDODataStoreException(javax.jdo.JDODataStoreException)

Aggregations

SQLException (java.sql.SQLException)1 JDODataStoreException (javax.jdo.JDODataStoreException)1 JDOFatalUserException (javax.jdo.JDOFatalUserException)1 JDOUserException (javax.jdo.JDOUserException)1 PersistenceManager (javax.jdo.PersistenceManager)1 Transaction (javax.jdo.Transaction)1 JDOPersistenceManager (org.datanucleus.api.jdo.JDOPersistenceManager)1 AReallyObnoxiouslyLongWindedNamedObject (org.datanucleus.samples.rdbms.datastore.AReallyObnoxiouslyLongWindedNamedObject)1