Package org.datanucleus.store.mapped.mapping

Examples of org.datanucleus.store.mapped.mapping.DiscriminatorStringMapping


            {
                // Backwards compatibility only. Creates discriminator in all subclass tables even though not needed
                // TODO Remove this in the future
                if (dismd.getStrategy() == DiscriminatorStrategy.CLASS_NAME)
                {
                    discriminatorMapping = new DiscriminatorStringMapping(dba, this,
                        mapMgr.getMapping(String.class));
                }
                else if (dismd.getStrategy() == DiscriminatorStrategy.VALUE_MAP)
                {
                    ColumnMetaData disColmd = dismd.getColumnMetaData();
                    if (disColmd != null && disColmd.getJdbcType() != null)
                    {
                        if (disColmd.getJdbcType().equalsIgnoreCase("INTEGER") ||
                                disColmd.getJdbcType().equalsIgnoreCase("BIGINT") ||
                                disColmd.getJdbcType().equalsIgnoreCase("NUMERIC"))
                        {
                            discriminatorMapping = new DiscriminatorLongMapping(dba, this,
                                mapMgr.getMapping(Long.class));
                        }
                        else
                        {
                            discriminatorMapping = new DiscriminatorStringMapping(dba, this,
                                mapMgr.getMapping(String.class));
                        }
                    }
                    else
                    {
                        discriminatorMapping = new DiscriminatorStringMapping(dba, this,
                            mapMgr.getMapping(String.class));
                    }
                }
            }
            else
            {
                // Create discriminator column only in top most table that needs it
                ClassTable tableWithDiscrim = getTableWithDiscriminator();
                if (tableWithDiscrim == this)
                {
                    // No superclass with a discriminator so add it in this table
                    if (dismd.getStrategy() == DiscriminatorStrategy.CLASS_NAME)
                    {
                        discriminatorMapping = new DiscriminatorStringMapping(dba, this,
                            mapMgr.getMapping(String.class));
                    }
                    else if (dismd.getStrategy() == DiscriminatorStrategy.VALUE_MAP)
                    {
                        ColumnMetaData disColmd = dismd.getColumnMetaData();
                        if (disColmd != null && disColmd.getJdbcType() != null)
                        {
                            if (disColmd.getJdbcType().equalsIgnoreCase("INTEGER") ||
                                    disColmd.getJdbcType().equalsIgnoreCase("BIGINT") ||
                                    disColmd.getJdbcType().equalsIgnoreCase("NUMERIC"))
                            {
                                discriminatorMapping = new DiscriminatorLongMapping(dba, this,
                                    mapMgr.getMapping(Long.class));
                            }
                            else
                            {
                                discriminatorMapping = new DiscriminatorStringMapping(dba, this,
                                    mapMgr.getMapping(String.class));
                            }
                        }
                        else
                        {
                            discriminatorMapping = new DiscriminatorStringMapping(dba, this,
                                mapMgr.getMapping(String.class));
                        }
                    }
                }
            }
View Full Code Here


  private void initializeDiscriminatorMapping(DiscriminatorMetaData dismd) {
    if (dismd != null) {
      discriminatorMetaData = dismd;
      if (dismd.getStrategy() == DiscriminatorStrategy.CLASS_NAME) {
        discriminatorMapping = new DiscriminatorStringMapping(
            dba, this, dba.getMappingManager(storeMgr).getMapping(String.class));
      } else if (dismd.getStrategy() == DiscriminatorStrategy.VALUE_MAP) {
        ColumnMetaData disColmd = dismd.getColumnMetaData();
        if (disColmd != null && disColmd.getJdbcType() != null) {
          if (disColmd.getJdbcType().equalsIgnoreCase("INTEGER")
              || disColmd.getJdbcType().equalsIgnoreCase("BIGINT")
              || disColmd.getJdbcType().equalsIgnoreCase("NUMERIC")) {
            discriminatorMapping = new DiscriminatorLongMapping(dba, this, dba
                .getMappingManager(storeMgr).getMapping(Long.class));
          } else {
            discriminatorMapping = new DiscriminatorStringMapping(
                dba, this, dba.getMappingManager(storeMgr).getMapping(String.class));
          }
        } else {
          discriminatorMapping = new DiscriminatorStringMapping(
              dba, this, dba.getMappingManager(storeMgr).getMapping(String.class));
        }
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.datanucleus.store.mapped.mapping.DiscriminatorStringMapping

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.