vidakovic commented on code in PR #4281:
URL: https://github.com/apache/fineract/pull/4281#discussion_r2041193050


##########
fineract-command/src/main/java/org/apache/fineract/command/persistence/converter/JsonAttributeConverter.java:
##########
@@ -0,0 +1,59 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.fineract.command.persistence.converter;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import jakarta.persistence.AttributeConverter;
+import jakarta.persistence.Converter;
+import lombok.RequiredArgsConstructor;
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+@RequiredArgsConstructor
+@Converter
+public class JsonAttributeConverter implements AttributeConverter<JsonNode, 
String> {

Review Comment:
   Well, I did this exercise already in a different setting and the JsonNode is 
actually already quite convenient when the rest of your infrastructure depends 
on Jackson anyway (which is the ultimate goal here). The only reason why these 
two data structures are persistent is for a specific use case, deferred 
execution (aka "maker-checker"), otherwise I would have left it out anyway. 
Overall I am not expecting that we will poke and peek too much into/from this 
data structure anyway, so the type actually doesn't matter too much. By default 
we are NOT saving every request, only those that are deferred (which should not 
be many)... and as they are deferred speed is counted in hours/days not 
milliseconds. And given that one of the main goals of this exercise is to 
introduce type-safety makes string kind of a wrong choice from my perspective.
   
   Concerning saving JSON data as a string: that is anyway a compromise. Both 
databases (MySQL and PostgreSQL) have specific data types for JSON (which is of 
course non-standard); unfortunately they have different approaches (I think 
PostgreSQL's is the better one) and it was impossible to abstract this away 
properly with JPA on the database side. That's why I fell back on the least 
common denominator (string). If we had only PostgreSQL I would have chosen 
their native JSON type (which would allow for proper querying... which we don't 
need). Just FYI.
   
   In short: I think this should be fine as is.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to