Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support of mariadb sequences fixes #883 #965

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import java.util.Collection;
import java.util.Hashtable;
import java.util.Vector;

import org.eclipse.persistence.exceptions.ValidationException;
import org.eclipse.persistence.expressions.ExpressionOperator;
import org.eclipse.persistence.internal.databaseaccess.DatabaseCall;
Expand Down Expand Up @@ -840,4 +839,51 @@ public boolean checkTableExists(final DatabaseSessionImpl session,
}
}

@Override
public boolean isAlterSequenceObjectSupported() {
return false;
}

/**
* INTERNAL:
* Returns sql used to create sequence object in the database.
*/
@Override
public Writer buildSequenceObjectCreationWriter(Writer writer, String fullSeqName, int increment, int start) throws IOException {
writer.write("CREATE SEQUENCE ");
writer.write(fullSeqName);
if(start != 1) {
writer.write(" START WITH " + start);
}
if (increment != 1) {
writer.write(" INCREMENT BY " + increment);
}
return writer;
}

/**
* INTERNAL:
* Returns sql used to delete sequence object from the database.
*/
@Override
public Writer buildSequenceObjectDeletionWriter(Writer writer, String fullSeqName) throws IOException {
writer.write("DROP SEQUENCE ");
writer.write(fullSeqName);
return writer;
}

@Override
public ValueReadQuery buildSelectQueryForSequenceObject(String seqName, Integer size) {
StringBuilder builder = new StringBuilder(26 + seqName.length());
builder.append("SELECT NEXTVAL(");
builder.append(seqName);
builder.append(")");
return new ValueReadQuery(builder.toString());
}

@Override
public boolean supportsSequenceObjects() {
return true;
}

}