Example usage for javax.persistence GenerationType toString

List of usage examples for javax.persistence GenerationType toString

Introduction

In this page you can find the example usage for javax.persistence GenerationType toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:org.apache.openjpa.persistence.AnnotationPersistenceMetaDataParser.java

static void parseDataStoreId(ClassMetaData meta, GenerationType strategy, String generator) {
    meta.setIdentityType(ClassMetaData.ID_DATASTORE);

    int strat = getGeneratedValueStrategy(meta, strategy, generator);
    if (strat != -1)
        meta.setIdentityStrategy(strat);
    else {//ww  w .j  a v a 2s .  c  om
        switch (strategy) {
        case TABLE:
        case SEQUENCE:
            // technically we should have separate system table and
            // sequence generators, but it's easier to just rely on
            // the system org.apache.openjpa.Sequence setting for both
            if (StringUtils.isEmpty(generator))
                meta.setIdentitySequenceName(SequenceMetaData.NAME_SYSTEM);
            else
                meta.setIdentitySequenceName(generator);
            break;
        case AUTO:
            meta.setIdentityStrategy(ValueStrategies.NATIVE);
            break;
        case IDENTITY:
            meta.setIdentityStrategy(ValueStrategies.AUTOASSIGN);
            break;
        default:
            throw new UnsupportedException(strategy.toString());
        }
    }
}

From source file:org.apache.openjpa.persistence.AnnotationPersistenceMetaDataParser.java

/**
 * Sets value generation information for the given field.
 *///  www . ja v a2 s .c  o  m
static void parseGeneratedValue(FieldMetaData fmd, GenerationType strategy, String generator) {
    int strat = getGeneratedValueStrategy(fmd, strategy, generator);
    if (strat != -1)
        fmd.setValueStrategy(strat);
    else {
        switch (strategy) {
        case TABLE:
        case SEQUENCE:
            // technically we should have separate system table and
            // sequence generators, but it's easier to just rely on
            // the system org.apache.openjpa.Sequence setting for both
            if (StringUtils.isEmpty(generator))
                fmd.setValueSequenceName(SequenceMetaData.NAME_SYSTEM);
            else
                fmd.setValueSequenceName(generator);
            break;
        case AUTO:
            fmd.setValueSequenceName(SequenceMetaData.NAME_SYSTEM);
            break;
        case IDENTITY:
            fmd.setValueStrategy(ValueStrategies.AUTOASSIGN);
            break;
        default:
            throw new UnsupportedException(strategy.toString());
        }
    }
}