From 79f4b84b7002c663c2fe5be4fba4b49534f8e31f Mon Sep 17 00:00:00 2001 From: LeoMoulin Date: Thu, 21 Mar 2024 14:39:17 +0100 Subject: [PATCH] Customisation of the RegNo --- .../main/java/ovh/herisson/Clyde/RegNoGenerator.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/backend/src/main/java/ovh/herisson/Clyde/RegNoGenerator.java b/backend/src/main/java/ovh/herisson/Clyde/RegNoGenerator.java index 783ceb7..23dc8c8 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/RegNoGenerator.java +++ b/backend/src/main/java/ovh/herisson/Clyde/RegNoGenerator.java @@ -3,10 +3,11 @@ package ovh.herisson.Clyde; import org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess; import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.id.IdentifierGenerator; -import java.sql.Connection; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; + +import java.sql.*; +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; public class RegNoGenerator implements IdentifierGenerator { private final UserSaveCounter usv = UserSaveCounter.getInstance(); @@ -24,8 +25,9 @@ public class RegNoGenerator implements IdentifierGenerator { ResultSet set = statement.executeQuery(query); long resp = 0; + Calendar c = new GregorianCalendar(); if(set.next()){ - resp = set.getLong(1)+1000; + resp = set.getLong(1)+((c.get(Calendar.YEAR)%1000)*10000); System.out.println(resp); }