Skip to content

Commit

Permalink
Entity Assist Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
GedMarc committed Sep 2, 2024
1 parent ec3580c commit 021a97d
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 12 deletions.
3 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@
<annotationProcessorPath>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>${maven.hibernate.version}</version>
<!--<version>${maven.hibernate.version}</version>-->
<version>6.4.8.Final</version>
</annotationProcessorPath>
<path>
<groupId>jakarta.xml.bind</groupId>
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/com/entityassist/BaseEntity.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.entityassist;

import com.entityassist.exceptions.QueryBuilderException;
import com.entityassist.querybuilder.QueryBuilder;
import com.entityassist.services.entities.IBaseEntity;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
Expand Down Expand Up @@ -43,8 +42,7 @@ public BaseEntity() {
@SuppressWarnings("unchecked")
@NotNull
public J persist() {
builder().persist((J) this);
return (J) this;
return builder().persist((J) this).getEntity();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public Long getCount()
}
catch (NoResultException nre)
{
Logger.getLogger(getClass().getName()).log(Level.WARNING, "Couldn''t find object with name : " + getEntityClass().getName() + "}\n", nre);
Logger.getLogger(getClass().getName()).log(Level.WARNING, "Couldn't find object with name : " + getEntityClass().getName(), nre);
return 0L;
}
}
Expand Down
23 changes: 16 additions & 7 deletions src/main/java/com/entityassist/querybuilder/QueryBuilderSCD.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
package com.entityassist.querybuilder;

import com.entityassist.*;
import com.entityassist.RootEntity;
import com.entityassist.SCDEntity;
import com.entityassist.enumerations.Operand;


import com.entityassist.enumerations.OrderByType;
import jakarta.validation.constraints.NotNull;

import java.io.Serializable;
import java.sql.SQLException;
import java.time.*;
import java.time.LocalDateTime;
import java.time.OffsetDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.logging.Level;
import java.util.logging.Logger;

import static com.entityassist.SCDEntity.*;
import static java.time.ZoneOffset.*;
import static com.entityassist.SCDEntity.EndOfTime;
import static com.entityassist.SCDEntity.getNow;
import static java.time.ZoneOffset.UTC;

@SuppressWarnings("unused")
public abstract class QueryBuilderSCD<J extends QueryBuilderSCD<J, E, I>, E extends SCDEntity<E, J, I>, I extends Serializable>
Expand Down Expand Up @@ -285,5 +289,10 @@ public static LocalDateTime convertToLocalDateTime(OffsetDateTime ldt, String ti
ZonedDateTime zonedDateTime = ldt.atZoneSameInstant(ZoneId.of(timezone));
return zonedDateTime.toLocalDateTime();
}


public J latestFirst()
{
orderBy(getAttribute(WAREHOUSE_UPDATED_DATE_COLUMN_NAME), OrderByType.DESC);
return (J)this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,14 @@ public J persist(E entity)
boolean transactionAlreadyStarted = false;
getEntityManager().persist(entity);
entity.setFake(false);
setEntity(entity);
}
}
catch (IllegalStateException ise)
{
Logger.getLogger(getClass().getName())
.log(Level.SEVERE, "This entity is not in a state to be persisted. Perhaps an update merge remove or refresh?", ise);
throw new UnsupportedOperationException(ise);
}
catch (Exception e)
{
Expand Down

0 comments on commit 021a97d

Please sign in to comment.