[DEBUG] remove deleted whan not needed
Some checks are pending
WEB karideo and rabbit/archidata/pipeline/head Build queued...

This commit is contained in:
Edouard DUPIN 2023-02-17 19:00:32 +01:00
parent fe3fc54b7b
commit 1d10ecb618
4 changed files with 26 additions and 3 deletions

View File

@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>kangaroo-and-rabbit</groupId>
<artifactId>archidata</artifactId>
<version>0.3.2</version>
<version>0.3.3</version>
<properties>
<jersey.version>3.1.1</jersey.version>
<jaxb.version>2.3.1</jaxb.version>
@ -50,6 +50,10 @@
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>

View File

@ -30,6 +30,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import org.kar.archidata.annotation.SQLCreateTime;
import org.kar.archidata.annotation.SQLDefault;
import org.kar.archidata.annotation.SQLDeleted;
public class SqlWrapper {
@ -706,6 +707,7 @@ public class SqlWrapper {
boolean firstField = true;
int count = 0;
boolean hasDeleted = false;
for (Field elem : clazz.getFields()) {
ModelLink linkGeneric = getLinkMode(elem);
if (linkGeneric != ModelLink.NONE) {
@ -715,6 +717,9 @@ public class SqlWrapper {
if (!full && createTime) {
continue;
}
if (!hasDeleted) {
hasDeleted = elem.getDeclaredAnnotationsByType(SQLDeleted.class).length != 0;
}
String name = elem.getName();
boolean updateTime = elem.getDeclaredAnnotationsByType(SQLUpdateTime.class).length != 0;
if (!full && updateTime) {
@ -735,7 +740,7 @@ public class SqlWrapper {
query.append(" FROM `");
query.append(tableName);
query.append("` ");
whereAppendQuery(query, tableName, condition, true);
whereAppendQuery(query, tableName, condition, firstField);
if (orderBy != null && orderBy.length() >= 1) {
query.append(" ORDER BY ");
//query.append(tableName);
@ -751,7 +756,7 @@ public class SqlWrapper {
query.append(".deleted = false ");
*/
firstField = true;
//System.out.println("generate the query: '" + query.toString() + "'");
System.out.println("generate the query: '" + query.toString() + "'");
// prepare the request:
PreparedStatement ps = entry.connection.prepareStatement(query.toString(), Statement.RETURN_GENERATED_KEYS);
whereInjectValue(ps, condition);

View File

@ -0,0 +1,12 @@
package org.kar.archidata.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface SQLDeleted {
}

View File

@ -6,6 +6,7 @@ import org.kar.archidata.annotation.SQLAutoIncrement;
import org.kar.archidata.annotation.SQLComment;
import org.kar.archidata.annotation.SQLCreateTime;
import org.kar.archidata.annotation.SQLDefault;
import org.kar.archidata.annotation.SQLDeleted;
import org.kar.archidata.annotation.SQLNotNull;
import org.kar.archidata.annotation.SQLNotRead;
import org.kar.archidata.annotation.SQLPrimaryKey;
@ -20,6 +21,7 @@ public class GenericTable {
@SQLNotRead
@SQLNotNull
@SQLDefault("'0'")
@SQLDeleted
@SQLComment("When delete, they are not removed, they are just set in a deleted state")
public Boolean deleted = null;
@SQLNotRead