Search in sources :

Example 46 with DatastoreAdapter

use of org.datanucleus.store.rdbms.adapter.DatastoreAdapter in project tests by datanucleus.

the class IdentifierFactoryTest method testJPOXTruncate.

/**
 * Verify that JPOXIdentifierFactory does truncation with a 2-character hashcode, as was done in JPOX
 * 1.2.0 (this had been changed to 4-character hashcode in datanucleus)
 */
public void testJPOXTruncate() {
    class SubclassForTesting extends JPOXIdentifierFactory {

        private SubclassForTesting(DatastoreAdapter dba, ClassLoaderResolver clr, Map props) {
            super(dba, clr, props);
        }

        public String publicTestTruncate(String string, int length) {
            return truncate(string, length);
        }
    }
    RDBMSStoreManager srm = (RDBMSStoreManager) storeMgr;
    SubclassForTesting jpoxCompatibilityIdentifierFactory = new SubclassForTesting(srm.getDatastoreAdapter(), new ClassLoaderResolverImpl(), new Properties());
    assertEquals("BIDIR_CONTAINED_LEVEL2_I2S", jpoxCompatibilityIdentifierFactory.publicTestTruncate("BIDIR_CONTAINED_LEVEL2_INTEGER", 26).toUpperCase());
}
Also used : JPOXIdentifierFactory(org.datanucleus.store.rdbms.identifier.JPOXIdentifierFactory) ClassLoaderResolver(org.datanucleus.ClassLoaderResolver) DatastoreAdapter(org.datanucleus.store.rdbms.adapter.DatastoreAdapter) Properties(java.util.Properties) HashMap(java.util.HashMap) Map(java.util.Map) RDBMSStoreManager(org.datanucleus.store.rdbms.RDBMSStoreManager) ClassLoaderResolverImpl(org.datanucleus.ClassLoaderResolverImpl)

Aggregations

DatastoreAdapter (org.datanucleus.store.rdbms.adapter.DatastoreAdapter)46 RDBMSStoreManager (org.datanucleus.store.rdbms.RDBMSStoreManager)24 SQLException (java.sql.SQLException)17 ManagedConnection (org.datanucleus.store.connection.ManagedConnection)10 ResultSet (java.sql.ResultSet)8 List (java.util.List)8 Connection (java.sql.Connection)7 Statement (java.sql.Statement)7 EntityTransaction (javax.persistence.EntityTransaction)7 NucleusDataStoreException (org.datanucleus.exceptions.NucleusDataStoreException)7 Person (org.datanucleus.samples.annotations.models.company.Person)7 JavaTypeMapping (org.datanucleus.store.rdbms.mapping.java.JavaTypeMapping)7 PreparedStatement (java.sql.PreparedStatement)6 ArrayList (java.util.ArrayList)6 SQLController (org.datanucleus.store.rdbms.SQLController)6 DatastoreClass (org.datanucleus.store.rdbms.table.DatastoreClass)6 StoredProcedureQuery (javax.persistence.StoredProcedureQuery)5 JPAEntityManager (org.datanucleus.api.jpa.JPAEntityManager)5 NucleusUserException (org.datanucleus.exceptions.NucleusUserException)5 AbstractClassMetaData (org.datanucleus.metadata.AbstractClassMetaData)5