Spring JPA. How to get only a list of IDs using #Query - spring-boot

I am trying to write this to fetch List and i have to pass the list of Ids as parameter :
#Query(value = "SELECT OutbreakDiagnosticTests FROM OutbreakDiagnosticTests WHERE OutbreakDiagnosticTests.outbreaks in (:outbreakIds) ")
List<OutbreakDiagnosticTests> getDiagnosticTestsByOutbreaks(#Param("outbreakIds") List<Long> outbreakIds);
My Entity is this that i am using to query is this :
#Entity
#EntityListeners(OutbreakDiagnosticTestManagerImpl.class)
#Table(name = "outbreak_diagnostic_tests")
public class OutbreakDiagnosticTests extends AbstractTemporalWorkingData implements Serializable{
/**
*
*/
private static final long serialVersionUID = 636298998880960358L;
#Id
#Column(nullable = false, name = "obdt_id")
#GeneratedValue(strategy = GenerationType.IDENTITY)
private long obdtId;
#Column(nullable = false, name = "nature", length = 255)
private String nature;
#Column(nullable = true, name = "diagnostic_test_req", length = 255)
private String diagnosticTestReq;
#OneToMany(mappedBy = "outbreakDiagnosticTests", cascade = CascadeType.ALL, orphanRemoval = true)
#Filter(name = "workingData")
private Set<TestsResults> testsResults;
#ManyToOne
#JoinColumn(name = "outbreak_id", nullable = false)
private Outbreaks outbreaks;
#ManyToOne
#JoinColumn(name = "diag_test_id", nullable = true)
private DiagnosticTests diagTests;
#ManyToOne
#JoinColumn(name = "lab_id", nullable = true)
private Laboratories lab;
#Column(nullable = false, name = "is_field")
private Boolean isField = false;
But i am getting this exception after running :
Error creating bean with name 'labTestSummariesDaoImpl': Unsatisfied dependency expressed through field 'obDiagTestRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'outbreakDiagnosticTestRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Validation failed for query for method public abstract java.util.List com.wahisplus.wcommon.repository.outbreak.OutbreakDiagnosticTestRepository.getDiagnosticTestsByOutbreaks(java.util.List)!
Can some one help me to fetch the List using the above method or can tell me what i am doing wrong in this.I dnt want to do using native i.e (nativeQuery = true) using this.

Use alias like OutbreakDiagnosticTests o and for select id, use o.outbreaks.id and make sure you autowired properly repository
#Query(value = "SELECT o FROM OutbreakDiagnosticTests o WHERE o.outbreaks.id IN (:outbreakIds) ")
List<OutbreakDiagnosticTests> getDiagnosticTestsByOutbreaks(#Param("outbreakIds") List<Long> outbreakIds);

Since you are already using Spring Data JPA, a method is provided OOTB:
List findAllById(Iterable ids);
This method takes in a List of non-null ids and returns you back the records against those Ids. Since you are not using DTO Concept and fetching al columns for a bundh of ids, why not use this method to work with.

Related

Spring data rest ManyToMany mapping PUT/update operation is not replacing the nested object

I started to learn spring data rest. I'm doing PUT operation and it's not working for the nested objects for ManyToMany relationship, whereas it works fine for OneToMany relation.
Entities structures:
#Table(name="CONFIG_DTLS",schema = "app_txn")
#Entity
public class Config {
#Id
#GenericGenerator(name = "UUIDGenerator", strategy = "uuid2")
#GeneratedValue(generator = "UUIDGenerator")
#Column(name = "ID", updatable = false, nullable = false)
private UUID id;
#Column(name = "NAME", nullable = false, length = 75)
private String name;
/*Unable to replace the data in the MBR_CONFIG_MAPPING table in the put operation.
When the control comes to #HandleBeforeSave annotated method in PUT operation,
the request data contains the existing Member info instead of the one which i'm passing in the PUT request body */
#ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE},fetch = FetchType.EAGER)
#JoinTable(schema = "app_txn", name = "MBR_CONFIG_MAPPING",
joinColumns ={#JoinColumn(name="CONFIG_ID",referencedColumnName = "ID")},
inverseJoinColumns = {#JoinColumn(name="MBR_ID",referencedColumnName = "ID")}
)
private Set<Member> members;
//able to replace the notifications completely in PUT operation
#OneToMany(cascade = CascadeType.ALL,fetch = FetchType.EAGER)
#JoinColumn(name = "CONFIG_ID",referencedColumnName = "ID")
private Set<Notification> notifications;
}
Member.java
#Table(name="MBR_DTLS",schema = "app_txn")
#Entity
public class Member {
#Id
#GenericGenerator(name = "UUIDGenerator", strategy = "uuid2")
#GeneratedValue(generator = "UUIDGenerator")
#Column(name = "ID", updatable = false, nullable = false)
private UUID id;
#Column(name = "OTHER_MBR_DATA", updatable = false)
private String otherMbrData;
}
Notification.java
#Table(name="NOTIFICATIONS",schema = "app_txn")
#Entity
public class Notification {
#Id
#GenericGenerator(name = "UUIDGenerator", strategy = "uuid2")
#GeneratedValue(generator = "UUIDGenerator")
#Column(name = "ID", updatable = false, nullable = false)
private UUID id;
#Column(name="LEVEL")
private String level;
#Column(name="EMAIL")
private String email;
}
Interfaces:
#RepositoryRestResource(collectionResourceRel = "configs", path="configs")
public interface ConfigRepo extends PagingAndSortingRepository<Config,UUID> {
}
#RepositoryRestResource(exported=false) // don't want to users to manipulate it directly.
public interface MemberRepo extends PagingAndSortingRepository<Member,Object> {
}
Here I don't want to add or modify anything in the MBR_DTLS table as it is loaded by another backend process. I want to update only the mapping details MBR_CONFIG_MAPPING table whenever user does the PUT/update operation. POST/create operation is working fine. Please share your thoughts on how to fix this and if you have any questions add it in the comment section.
PS: I referred some links online but that does not help much - Spring Data REST - PUT request does not work properly since v.2.5.7

ERROR: syntax error at or near "." - JPA Pageable

repository:
#Repository
public interface PostRepository extends PagingAndSortingRepository<Post, Long> {
#Query(value = "SELECT p.postComments FROM Post p WHERE p.webId = ?1")
Page<PostComment> findCommentsByWebId(String webid, Pageable pageable);
}
Post entity:
public class Post {
#Id
#GeneratedValue(strategy = GenerationType.IDENTITY)
#Column(name = "id")
private Long id;
#Column(name = "web_id")
private String webId;
#Column(nullable = false, name = "title")
private String title;
#Column(nullable = false, name = "description")
private String description;
#Column(nullable = false, name = "mature")
private boolean mature;
#OneToOne(mappedBy = "post")
private Cover cover;
#ManyToOne
#JoinColumn(name = "user_id")
private User user;
#OneToMany(mappedBy = "post")
private List<PostView> postViews;
#ManyToMany
#JoinTable(name = "post_tag",
joinColumns = #JoinColumn(name = "post_id"),
inverseJoinColumns = #JoinColumn(name = "tag_id"))
private List<Tag> tags;
#OneToMany(mappedBy = "post")
private List<PostDownvote> postDownvotes;
#OneToMany(mappedBy = "post")
private List<PostUpvote> postUpvotes;
#OneToMany(mappedBy = "post")
private List<PostComment> postComments;
#Column(name = "created_at")
private Timestamp createdAt;
#Column(name = "updated_at")
private Timestamp updatedAt;
}
The problem: When returning plain List<PostComment> from the query method everything works fine. But if I change it to Page<PostComment> (I need total elements count), I get the following error:
2022-08-03 22:29:41.399 ERROR 9192 --- [nio-8080-exec-3] o.h.engine.jdbc.spi.SqlExceptionHelper : ERROR: syntax error at or near "."
Position: 14
Hibernate: select tags0_.post_id as post_id1_6_0_, tags0_.tag_id as tag_id2_6_0_, tag1_.id as id1_10_1_, tag1_.name as name2_10_1_ from post_tag tags0_ inner join tag tag1_ on tags0_.tag_id=tag1_.id where tags0_.post_id=?
org.springframework.dao.InvalidDataAccessResourceUsageException: could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet
It is very difficult to debug this. Does anyone have any clue on what is wrong?
I need BOTH paging and total amount of elements.
Basically you are not able to fetch the part of the inner collection. But you could reach it from the another side of the bi-directional relationship
#Repository
public interface PostCommentRepository extends PagingAndSortingRepository<PostComment, Long> {
#Query(value = "SELECT pc FROM PostComment pc WHERE pc.post.webId = ?1")
Page<PostComment> findCommentsByWebId(String webid, Pageable pageable);
// or better using Spring Data naming conventions just
Page<PostComment> findAllByPostWebId(String webid, Pageable pageable);
}
If you only need a total count you should avoid querying list of entities which could be very memory intensive.
So in your PostCommentRepository try the following:
long countAllByPost_WebId(String webId);

Unable to fetch Orders(which are not deleted) for logged in user

I am trying to fetch orders for logged in User which I was able to do. But now I have to orders for logged in User which are not marked as deleted as well. I am facing issue to fetch these records using spring-data-jpa. Same scenario I want to implement on User End.I am getting below exception -
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-09-02 05:31:03.699 ERROR 220 --- [ restartedMain] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'adminController': Unsatisfied dependency expressed through field 'journeyFoodServiceImpl'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'journeyFoodServiceImpl' defined in file [C:\Users\TiaaUser\Desktop\AWS\journeyfood\target\classes\org\brahmakumaris\journeyfood\service\JourneyFoodServiceImpl.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'journeyFoodOrderRepository' defined in org.brahmakumaris.journeyfood.repository.JourneyFoodOrderRepository defined in #EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Invocation of init method failed; nested exception is java.lang.IllegalStateException: Using named parameters for method public abstract java.util.List org.brahmakumaris.journeyfood.repository.JourneyFoodOrderRepository.findOrderByUserIdAndNotDisabled(long,boolean) but parameter 'Optional[userId]' not found in annotated query 'SELECT j.orderId,j.headCount,j.dateOfDeparture,j.dateOfOrderPlaced,j.mealRetrievalTime,j.achar,
j.bread,j.jam,j.puri,j.thepla,j.roti,j.others from JourneyFoodOrder j INNER JOIN users u on u.userId=?1 WHERE j.isRemoved=:isRemoved'!
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:660)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1413)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:601)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:524)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
Caused by: java.lang.IllegalStateException: Using named parameters for method public abstract java.util.List org.brahmakumaris.journeyfood.repository.JourneyFoodOrderRepository.findOrderByUserIdAndNotDisabled(long,boolean) but parameter 'Optional[userId]' not found in annotated query 'SELECT j.orderId,j.headCount,j.dateOfDeparture,j.dateOfOrderPlaced,j.mealRetrievalTime,j.achar,
j.bread,j.jam,j.puri,j.thepla,j.roti,j.others from JourneyFoodOrder j INNER JOIN users u on u.userId=?1 WHERE j.isRemoved=:isRemoved'!
at org.springframework.data.jpa.repository.query.JpaQueryMethod.assertParameterNamesInAnnotatedQuery(JpaQueryMethod.java:172)
at org.springframework.data.jpa.repository.query.JpaQueryMethod.<init>(JpaQueryMethod.java:139)
at org.springframework.data.jpa.repository.query.DefaultJpaQueryMethodFactory.build(DefaultJpaQueryMethodFactory.java:44)
at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$AbstractQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:81)
at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.lookupQuery(QueryExecutorMethodInterceptor.java:100)
Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: Path expected for join! [SELECT j.orderId,j.headCount,j.dateOfDeparture,j.dateOfOrderPlaced,j.mealRetrievalTime,j.achar,
j.bread,j.jam,j.puri,j.thepla,j.roti,j.others from org.brahmakumaris.journeyfood.entity.JourneyFoodOrder j INNER JOIN users u on u.userId=:userId WHERE j.isRemoved=:isRemoved]
at org.hibernate.hql.internal.ast.QuerySyntaxException.convert(QuerySyntaxException.java:74)
JourneyFoodOrder.java Here isRemoved is getting used for marking orders as deleted.
#Entity
public class JourneyFoodOrder{
#Id
#GeneratedValue(strategy = GenerationType.AUTO)
private long orderId;
private int headCount;
#DateTimeFormat(pattern = "dd/MM/yyyy")
private Date dateOfOrderPlaced;
#DateTimeFormat(pattern = "dd/MM/yyyy")
private Date dateOfDeparture;
#DateTimeFormat(pattern = "dd/MM/yyyy h:mm a")
private Date mealRetrievalTime;
#ManyToOne
private UserEntity user;
private int thepla;
private int puri;
private int roti;
private int achar;
private int jam;
private int bread;
private int others;
private boolean isRemoved;
//Getter setter and constructors
}
UserEntity.java Here isDisabled is used for marking User as disabled and enabled field for enabling(User verification via email).
#Entity
#Table(name="users")
public class UserEntity {
#Id
#Column(unique = true, nullable = false)
#GeneratedValue(strategy = GenerationType.AUTO)
private long userId;
#ManyToMany(fetch = FetchType.EAGER)
#JoinTable(name = "users_roles", joinColumns = #JoinColumn(name = "user_id", referencedColumnName = "userId"), inverseJoinColumns = #JoinColumn(name = "role_id", referencedColumnName = "roleId"))
private Set<Role> roles;
#Column(nullable = false, length = 100)
private String nameOfCenter;
#Column(nullable = false, length = 100)
private String nameOfGuide;
#Column(nullable = false, length = 18)
private String contactNoOfGuide;
#Column(nullable = false, unique = true, length = 70)
private String email;
#Column(nullable = false, length = 70)
private String zone;
#Column(nullable = false, length = 70)
private String subZone;
#Column(length = 10)
private Integer pincode;
private Date dateCreated;
private boolean isDisabled;
#Column(nullable = false, length = 150)
private String password;
#Column(nullable = false)
#Type(type = "org.hibernate.type.NumericBooleanType")
private boolean enabled;//whether account is verified using email or not
#OneToMany(mappedBy = "user")
#Fetch(FetchMode.JOIN)
private List<JourneyFoodOrder> order;
//Getters, setters and constructor
}
JourneyFoodOrderRepository.java
#Repository
public interface JourneyFoodOrderRepository extends JpaRepository<JourneyFoodOrder, Long>{
#Override
void delete(JourneyFoodOrder order);
#Modifying
#Query("update JourneyFoodOrder j set j.isRemoved =true where j.orderId =:id")
void updateIsRemoved(#Param("orderId")Long orderId);
List<JourneyFoodOrder> findByIsRemoved(boolean isRemoved);
#Modifying
#Query("SELECT j.orderId,j.headCount,j.dateOfDeparture,j.dateOfOrderPlaced,j.mealRetrievalTime,j.achar,\r\n"
+ "j.bread,j.jam,j.puri,j.thepla,j.roti,j.others from JourneyFoodOrder j INNER JOIN users u on u.userId=:userId WHERE j.isRemoved=:isRemoved")
List<JourneyFoodOrder> findOrderByUserIdAndNotDisabled(#Param("userId") long userId, #Param("isRemoved") boolean isRemoved);
}
Please help me out in resolving this issue.
In your for findOrderByUserIdAndNotDisabled method query, you have set method parameter as this j.isRemoved=:isRemoved. It should be change to j.isRemoved= ?2.
Here is the corrected Query
#Query("SELECT j.orderId,j.headCount,j.dateOfDeparture,j.dateOfOrderPlaced,j.mealRetrievalTime,j.achar,"
+ "j.bread,j.jam,j.puri,j.thepla,j.roti,j.others from JourneyFoodOrder j INNER JOIN users u on u.userId=?1 WHERE j.isRemoved= ?2")
I was using wrong Entity name causing this issue -
#Query("SELECT j.orderId,j.headCount,j.dateOfDeparture,j.dateOfOrderPlaced,j.mealRetrievalTime,j.achar,\r\n"
+ "j.bread,j.jam,j.puri,j.thepla,j.roti,j.others from JourneyFoodOrder j INNER JOIN UserEntity u on u.userId=:userId WHERE j.isRemoved=:isRemoved")
List<JourneyFoodOrder> findOrderByUserIdAndNotDisabled(#Param("userId") long userId, #Param("isRemoved") boolean isRemoved);
editing users to UserEntity did resolved my issue.

Spring JPA Self Reference Issue

I created a table, Category in Postgres which holds both parent and child categories and references to itself (it's a self join table)
The table comprises of following columns: id, parent_id, start_date, end_date, status
I also have one row for root parent whose id = 0. So, any first level categories have root as its parent.
Example: Apparel > Women. Here Apparel(id=1) is a first level category whose parent_id = 0. Women is another category whose parent_id = 1.
I am using Spring JpaRepository findAll on my table and this is leading to infinite recursion.
POJO
#Table(name = "ofr_category")
#Getter
#Setter
#NoArgsConstructor
public class Category {
#Id
#Column(name = "cat_id", updatable = true, unique = true, nullable = false)
#GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "CATEGORY_SEQ")
#SequenceGenerator(sequenceName = "CATEGORY_ID_SEQ", allocationSize = 1, name = "CATEGORY_SEQ")
private Long id;
#Column(name = "cat_name")
private String name;
#Column(name = "cat_status")
private String status;
#Column(name = "start_date")
private LocalDate startDate;
#Column(name = "end_date")
private LocalDate endDate;
#Column(name = "parent_id")
private Long parentId;
#JsonBackReference
#ManyToOne(fetch = FetchType.LAZY)
#JoinColumn(name = "parent_id", insertable = false, updatable = false)
private Category parentCategory;
#JsonManagedReference
#OneToMany(fetch = FetchType.EAGER, mappedBy = "parentCategory")
private List<Category> childCategories;
public Category getParentCategory(){
return parentCategory;
}
}
Exception seen
"Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Direct self-reference leading to cycle (through reference chain: java.util.ArrayList[0]->com.test.category.dataobject.Category[\"parentCategory\"]->com.test.category.dataobject.Category[\"parentCategory\"]->com.test.category.dataobject.Category[\"parentCategory\"])",
Maybe you can have a look into #JsonIdentityInfo, which solved a similar problem for me. You can check if this basic annotation works for you.:
#JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
public class Category {
...
}

Spring Data Rest 2.1.0 Cannot POST or PUT Complex Resource

EDIT: This appears to be happening with PUTs as well.
Using spring-data-rest-webmvc version 2.1.0.BUILD-SNAPSHOT I have found that I am unable to POST a resource with a relation pointing to an already existing resource. I have 2 such entities which require references to be instantiated and POSTing to either of their endpoints results in the behavior below.
POSTing a resource without required references works well.
I did a bit of digging and it appears that PersistentEntityResourceHandlerMethodArgumentResolver finds the MappingJackson2HttpMessageConverter just fine, but it ends up throwing an exception while checking whether the ObjectMapper can deserialize the type. The cause of the exception is a NullPointerException.
example POST w/ relations to /reservations:
{
"description" : "test_post",
"dateMade" : "2014-03-03T08:04:44.293-0600",
"timeLastChanged" : null,
"userLastChanged" : null,
"courseTypeId" : null,
"numCredits" : null,
"instructor" : null,
"numParticipants" : null,
"reservationType" : "MCU",
"status" : "REQUESTED",
"abstract" : null,
"requestor" : "http://localhost:8080/users/2",
"submitter" : "http://localhost:8080/users/2",
"conferences" : []
}
RESPONSE:
{
cause: null
message: "No suitable HttpMessageConverter found to read request body into object of type class domain.Reservation from request with content type of application/json!"
}
POST w/ no relations to /roomGroups:
{
"description" : "All Rooms",
"isOffNetwork" : false,
"roomGroupType" : "STANDARD"
}
RESPONSE:
201 Created
Is there something wrong about the JSON I am POSTing which is resulting in an NPE from the ObjectMapper? Is there a workaround of some kind? This was working for me in 2.0.0.RC1 using a slightly different scheme for including reference links in the JSON and since the version of the Jackson dependencies appears to have stayed the same I wonder what is causing this issue...
Thanks for any help!
UPDATE:
This issue now seems un-related to the associated entities...
I created a new #Entity ConnectionRequest as follows:
#Id
#GeneratedValue(strategy = GenerationType.AUTO)
#Column(name = "CONNECTION_REQUEST_ID")
private Long id;
#Column(name = "FROM_ENTITY_ID", nullable = false)
private Long fromId;
#Column(name = "TO_ENTITY_ID", nullable = false)
private Long toId;
#Convert(converter = EntityTypeConverter.class)
#Column(name = "FROM_ENTITY_TYPE_ID", nullable = false)
private EntityType fromType;
#Convert(converter = EntityTypeConverter.class)
#Column(name = "TO_ENTITY_TYPE_ID", nullable = false)
private EntityType toType;
#ManyToOne(fetch = FetchType.EAGER, cascade = {CascadeType.MERGE})
#JoinColumn(name = "CONFERENCE_ID", nullable = false)
private Conference conference;
I can POST a new ConnectionRequest record with a Conference relation included in the json as such {"conference" : ".../conferences/1"}.
I am however still getting the same exception w/ this #Entity Reservation:
#Id
#GeneratedValue(strategy = GenerationType.AUTO)
#Column(name = "RESERVATION_ID")
private Long id;
#Column(name = "DESCRIPTION", length = 50, nullable = false)
private String description;
#Temporal(TemporalType.TIMESTAMP)
#Column(name = "DATE_MADE", nullable = false)
private Date dateMade;
#Temporal(TemporalType.TIMESTAMP)
#Column(name = "TIME_LAST_CHANGED")
private Date timeLastChanged;
#Column(name = "USER_LAST_CHANGED")
private Integer userLastChanged; // TODO why is this an int?
#Column(name = "ABSTRACT", length = 2000)
private String _abstract;
#Column(name = "COURSE_TYPE_ID")
private Integer courseTypeId;
#Column(name = "NUMBER_OF_CREDITS")
private Integer numCredits;
#Column(name = "INSTRUCTOR", length = 255)
private String instructor;
#Column(name = "NUMBER_OF_PARTICIPANTS")
private Integer numParticipants;
#Convert(converter = ReservationTypeConverter.class)
#Column(name = "RESERVATION_TYPE_ID", nullable = false)
private ReservationType reservationType;
#Convert(converter = StatusConverter.class)
#Column(name = "STATUS_ID")
private Status status;
#ManyToOne(fetch = FetchType.EAGER, cascade = {CascadeType.MERGE})
#JoinColumn(name="REQUESTOR_USER_ID", nullable=false)
private User requestor;
#ManyToOne(fetch = FetchType.EAGER, cascade = {CascadeType.MERGE})
#JoinColumn(name="SUBMITTER_USER_ID", nullable=false)
private User submitter;
#OneToMany(fetch = FetchType.LAZY, mappedBy = "reservation", cascade = {CascadeType.REMOVE})
private Set<Conference> conferences = new HashSet<>();
I'm not sure what's special about this class that's causing things to go awry...
The issue was the following:
Both of the non-postable entities had a property called _abstract due to it being a reserved word in Java. I had named the getter and setter for this property getAbstract() and setAbstract() respectively.
Jackson appears to have been throwing a null pointer exception since the getter and setter did not match the property name as expected.
When I changed the property name to resvAbstract and updated the accessors to getResvAbstract() and setResvAbstract() everything came together and started working.
I'm still curious about the change that led to this issue showing up, but I'm glad it's working!

Resources