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

com.samskivert.depot.clause.InsertClause Maven / Gradle / Ivy

The newest version!
//
// Depot library - a Java relational persistence library
// https://github.com/threerings/depot/blob/master/LICENSE

package com.samskivert.depot.clause;

import java.util.Collection;
import java.util.Set;

import com.samskivert.depot.PersistentRecord;
import com.samskivert.depot.impl.FragmentVisitor;

/**
 * Builds actual SQL given a main persistent type and some {@link QueryClause} objects.
 */
public class InsertClause implements QueryClause
{
    public InsertClause (Class pClass, Object pojo,
                         Set identityFields)
    {
        _pClass = pClass;
        _pojo = pojo;
        _idFields = identityFields;
    }

    public Class getPersistentClass ()
    {
        return _pClass;
    }

    public Object getPojo ()
    {
        return _pojo;
    }

    public Set getIdentityFields ()
    {
        return _idFields;
    }

    // from SQLExpression
    public void addClasses (Collection> classSet)
    {
        classSet.add(_pClass);
        // If we add SQLExpression[] values INSERT, remember to recurse into them here.
    }

    // from SQLExpression
    public Object accept (FragmentVisitor builder)
    {
        return builder.visit(this);
    }

    protected Class _pClass;

    /** The object from which to fetch values, or null. */
    protected Object _pojo;

    protected Set _idFields;
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy