All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.datanucleus.store.rdbms.request.RequestIdentifier Maven / Gradle / Ivy

/**********************************************************************
Copyright (c) 2002 Kelly Grizzle (TJDO) and others. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Contributors:
2009 Andy Jefferson - removed hardcoded type, changed to use RequestType enum
    ...
**********************************************************************/
package org.datanucleus.store.rdbms.request;

import java.util.Arrays;
import java.util.BitSet;
import java.util.Objects;

import org.datanucleus.metadata.AbstractMemberMetaData;
import org.datanucleus.store.rdbms.table.DatastoreClass;

/**
 * Representation of a request id.
 */
public class RequestIdentifier
{
    private final DatastoreClass table;
    private final int[] memberNumbers;
    private final int[] secondaryMemberNumbers;
    private final RequestType type;
    private final int hashCode;
    private final String className;
    private final BitSet nullPkFields;
    private final boolean noVersionUpdate;

    /**
     * Constructor.
     * @param table Datastore class for which this is a request
     * @param mmds MetaData of fields/properties to use in the request (if required)
     * @param type The type being represented
     * @param className The name of the class
     */
    public RequestIdentifier(DatastoreClass table, AbstractMemberMetaData[] mmds, RequestType type, String className)
    {
        this(table, mmds, null, type, className, null);
    }

    /**
     * Constructor.
     *
     * @param table         Datastore class for which this is a request
     * @param mmds          MetaData of members to use in the request (if required)
     * @param secondaryMmds MetaData of secondary members to use the in the request
     * @param type          The type being represented
     * @param className     The name of the class
     * @param nullPkFields  PK fields that are null
     */
    public RequestIdentifier(DatastoreClass table, AbstractMemberMetaData[] mmds, AbstractMemberMetaData[] secondaryMmds, RequestType type, String className, BitSet nullPkFields)
    {
        this(table, mmds, secondaryMmds, type, className, nullPkFields, false);
    }

    /**
     * Constructor.
     *
     * @param table         Datastore class for which this is a request
     * @param mmds          MetaData of members to use in the request (if required)
     * @param secondaryMmds MetaData of secondary members to use the in the request
     * @param type          The type being represented
     * @param className     The name of the class
     * @param nullPkFields  PK fields that are null
     * @param noVersionUpdate Should we ignore updating version when using optimistic lock?
     */
    public RequestIdentifier(DatastoreClass table, AbstractMemberMetaData[] mmds, AbstractMemberMetaData[] secondaryMmds, RequestType type, String className, BitSet nullPkFields, boolean noVersionUpdate)
    {
        this.table = table;
        this.type = type;
        this.className = className;
        this.nullPkFields = nullPkFields;
        this.noVersionUpdate = noVersionUpdate;

        if (mmds == null)
        {
            this.memberNumbers = null;
        }
        else
        {
            this.memberNumbers = new int[mmds.length];
            for (int i=0;i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy