Customisation of the RegNo

This commit is contained in:
LeoMoulin 2024-03-21 14:39:17 +01:00
parent 0c73f6f44d
commit 79f4b84b70

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);
} }