Package nexj.core.meta.persistence.sql

Examples of nexj.core.meta.persistence.sql.RelationalSchema$Fixup


      if (dataSource instanceof RelationalDatabase)
      {
         RelationalDatabase database = (RelationalDatabase)dataSource;
         SQLAdapter adapter = (SQLAdapter)database.getComponent().getInstance(m_context);
         SQLSchemaManager manager = adapter.createSchemaManager(database);
         RelationalSchema schema = (RelationalSchema)database.getSchema();
         String sOrigFragment = m_context.getFragmentName();
         Connection connection = null;

         try
         {
View Full Code Here


      if (dataSource instanceof RelationalDatabase)
      {
         RelationalDatabase database = (RelationalDatabase)dataSource;
         SQLAdapter adapter = (SQLAdapter)database.getComponent().getInstance(m_context);
         SQLSchemaManager manager = adapter.createSchemaManager(database);
         RelationalSchema schema = (RelationalSchema)database.getSchema();
         String sOrigFragment = m_context.getFragmentName();
         Connection connection = null;

         try
         {
View Full Code Here

      {
         con = m_adapter.getConnectionFactory().getConnection(m_adapter);

         if (!bLocked) // lock acquired previously, therefore schema created, only truncate
         {
            RelationalSchema schema = (RelationalSchema)m_database.getSchema();
            SQLSchemaManager manager = m_adapter.createSchemaManager(m_database);
            SQLConnectionAppender appender = new SQLSchemaManager.SQLConnectionAppender(con, true);

            appender.setLogLevel(Logger.DUMP);
            manager.setSQLAppender(appender);
View Full Code Here

            txManager.setTransactionTimeout(0);

            // use separate connection for creating schema since DDL operations might issue commit
            con = m_adapter.getConnectionFactory().getConnection(m_adapter);

            RelationalSchema schema = (RelationalSchema)m_database.getSchema();
            SQLSchemaManager manager = m_adapter.createSchemaManager(m_database);
            SQLConnectionAppender appender = new SQLSchemaManager.SQLConnectionAppender(con, true);

            // recreate test schema
            appender.setLogLevel(Logger.DUMP);
View Full Code Here

         null, -1, 0, false, Query.SEC_NONE, m_context).read().size());
   }

   public void testSchemaUnicodeValidation() throws Exception
   {
      RelationalSchema schema = (RelationalSchema)m_database.getSchema();
      Table origVersionTable = schema.getVersionTable(); // note original
      Table versionTable = schema.getTable("Version");
      RelationalDatabase origDS = (RelationalDatabase)schema.getDataSource();
      RelationalDatabase ds = (RelationalDatabase)origDS.clone();

      try
      {
         schema.setDataSource(ds);
         schema.setVersionTable(versionTable);

         try
         {
            m_adapter.getVersion(schema); // one of getVersion() has to throw exception
            ds.setUnicode(!ds.isUnicode()); // try the oposite Unicode flag
            m_adapter.getVersion(schema); // one of getVersion() has to throw exception
            fail("Unicode flag validation exception expected.");
         }
         catch (UncheckedException e)
         {
            // test online upgrade prevention
            assertEquals("err.persistence.sql.unicodeMismatch", e.getErrorCode());
         }

         // ensure correct result was provided as per the created schema
         SQLConnection con = m_adapter.getConnection();
         Statement stmt = null;
         ResultSet rs = null;

         try
         {
            stmt = con.getConnection().createStatement();
            rs = stmt.executeQuery(
               "select namespace from " +
               versionTable.getFullName(m_adapter.createSchemaManager().getOwner()));

            // 1 == the namespace column
            assertEquals(Boolean.valueOf(origDS.isUnicode()), m_adapter.isUnicode(schema, rs, 1));
         }
         finally
         {
            try
            {
               if (rs != null)
               {
                  rs.close();
               }
            }
            catch (Throwable t)
            {}

            try
            {
               if (stmt != null)
               {
                  stmt.close();
               }
            }
            catch (Throwable t)
            {}

            con.decRef();
         }

         StringWriter writer = new StringWriter();
         SQLSchemaManager manager = m_adapter.createSchemaManager();

         manager.setSQLAppender(manager.new SQLWriterAppender(writer));
         manager.upgrade(schema);

         // test offline upgrade script guard generation
         assertTrue(writer.toString().contains(getUnicodeCheckGuard(ds.isUnicode())));

         ds.setUnicode(!ds.isUnicode()); // try the oposite Unicode flag
         writer = new StringWriter();
         manager.setSQLAppender(manager.new SQLWriterAppender(writer));
         manager.upgrade(schema);

         // test offline upgrade script guard generation
         assertTrue(writer.toString().contains(getUnicodeCheckGuard(ds.isUnicode())));
      }
      finally
      {
         schema.setVersionTable(origVersionTable); // reset so testUpgrade() will not fail
         schema.setDataSource(origDS); // reset to original
      }
   }
View Full Code Here

TOP

Related Classes of nexj.core.meta.persistence.sql.RelationalSchema$Fixup

Copyright © 2018 www.massapicom. 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.