WIP: Leo/Backend/RegNo #147

Closed
LeoMoulin wants to merge 6 commits from Leo/Backend/RegNo into master
Showing only changes of commit 79f4b84b70 - Show all commits

View File

@ -3,10 +3,11 @@ package ovh.herisson.Clyde;
import org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess; import org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess;
import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.id.IdentifierGenerator; import org.hibernate.id.IdentifierGenerator;
import java.sql.Connection;
import java.sql.ResultSet; import java.sql.*;
import java.sql.SQLException; import java.util.Calendar;
import java.sql.Statement; import java.util.Date;
import java.util.GregorianCalendar;
public class RegNoGenerator implements IdentifierGenerator { public class RegNoGenerator implements IdentifierGenerator {
private final UserSaveCounter usv = UserSaveCounter.getInstance(); private final UserSaveCounter usv = UserSaveCounter.getInstance();
@ -24,8 +25,9 @@ public class RegNoGenerator implements IdentifierGenerator {
ResultSet set = statement.executeQuery(query); ResultSet set = statement.executeQuery(query);
long resp = 0; long resp = 0;
Calendar c = new GregorianCalendar();
if(set.next()){ if(set.next()){
resp = set.getLong(1)+1000; resp = set.getLong(1)+((c.get(Calendar.YEAR)%1000)*10000);
System.out.println(resp); System.out.println(resp);
} }