openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Dick" <michael.d.d...@gmail.com>
Subject Re: svn commit: r492225 - in /incubator/openjpa/trunk: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/ openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/meta/ openjpa-persisten
Date Thu, 04 Jan 2007 19:37:56 GMT
I'm a little unclear on why the code is in ClassMapping, too. It seems like
it could go in the SchemaGenerator along with generatePrimaryKeys(),
generateIndexes(), etc.

Pinaki, is there any reason why we can't move the code into a more common
location?

On 1/3/07, Abe White <awhite@bea.com> wrote:
>
> I don't agree with this implementation.  It doesn't leave any room
> for customization through MappingDefaults, it ties the ClassMapping
> to the XMLSchemaParser (?!), and it's totally different than our
> mapping of indexes, foreign keys, and primary keys, the other
> supported constraint types.
>
> > +        mapUniqueConstraints();
> > +    }
> > +
> > +    /**
> > +     * Adds unique constraints to the mapped table.
> > +     *
> > +     */
> > +    void mapUniqueConstraints() {
> > +        Log log = getRepository().getLog();
> > +        Collection uniqueInfos = _info.getUniqueConstraints();
> > +        if (uniqueInfos == null || uniqueInfos.isEmpty())
> > +            return;
> > +        Iterator iter = uniqueInfos.iterator();
> > +        Table table = getTable();
> > +        int i = 1;
> > +        while (iter.hasNext()) {
> > +            XMLSchemaParser.UniqueInfo uniqueInfo =
> > +                (XMLSchemaParser.UniqueInfo)iter.next();
> > +            if (uniqueInfo.cols == null || uniqueInfo.cols.isEmpty())
> > +                continue;
> > +            String constraintName = table.getName() + "_UNIQUE_" + i;
> > +            i++;
> > +            Unique uniqueConstraint = table.addUnique
> > (constraintName);
> > +            Iterator uniqueColumnNames = uniqueInfo.cols.iterator();
> > +            while (uniqueColumnNames.hasNext()) {
> > +                String uniqueColumnName = (String)
> > uniqueColumnNames.next();
> > +                Column uniqueColumn = table.getColumn
> > (uniqueColumnName);
> > +                if (uniqueColumn != null) {
> > +                    uniqueConstraint.addColumn(uniqueColumn);
> > +                } else {
> > +                    table.removeUnique(uniqueConstraint);
> > +                    if (log.isWarnEnabled())
> > +                        log.warn(_loc.get("missing-unique-column",
> > this,
> > +                            table.getName(), uniqueColumnName));
> > +                    break;
> > +                }
> >              }
> >          }
> >      }
> _______________________________________________________________________
> Notice:  This email message, together with any attachments, may contain
> information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
> entities,  that may be confidential,  proprietary,  copyrighted  and/or
> legally privileged, and is intended solely for the use of the individual
> or entity named in this message. If you are not the intended recipient,
> and have received this message in error, please immediately return this
> by email and then delete it.
>



-- 
-Michael Dick

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message