Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!

Geane Norm

Ranch Hand
+ Follow
since Feb 01, 2016
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Geane Norm

Hi all,
I have the following enum:

Each of the class (e.g. ClassOne) is a data class implementing interface MyClass<Entity> as follows:

My issue is that I have a method taking each of the mapped classes as an argument and I am trying to find a way to make it more generic by getting the corresponding class per enum. I have written the following:

which correctly returns the mapped class, however i am struggling to correctly using it here:

Essentially I want to avoid replicating the method signature by not having to pass in the concrete mappedClass as a parameter. The issue is that the returns , while the savedEvent is expecting the concrete data class . I have attempted at casting it to MyClass to Entity, but with no luck. Can you help? As it stands, I now have 3 identical methods whose only difference is the abovementioned argument/parameter.

Thank you for your help

1 month ago

Liutauras Vilda wrote:Hi Geane,

I find it confusing to understand the task. I have some ideas what you might want to do, but I have to admit that code looks confusing at the moment.

1. First, I think your chosen variables are misleading or not intuitive.


So this one the way I understand is, given the Status A, to which status it might go to from Status A, right? Not sure why you call it expectedStatus.

I'd call them along the lines: currentStatus -> nextStatus or transitionStatus, because having expectedStatus one may think, ok, it was given start Status A, but actually was expected Status B - see where the confusion may arise?


But what actually you have inside, is a list of States not Statuses.

2. In the other snippet of code you have

What this one supposed to achieve? As currently it does nothing in my understanding.

So if you ask me. I'd make those things clearer and delete parts of code which are not used, that way I'd find easier to understand where things fall apart, although lately I'm not that proficient in Kotlin.

Hi, thank you for your reply. So my map will look something like this:

As you can see a list of values can match a key (e.g. C=[B, E, D]), however the validator works with pairs. My expected result is to be returned with TRUE every time a pair is matched. Can you help? I am not really sure what I am missing here

Thank you

2 months ago
I have the following:

I would need to write a validator that takes the initial status and return the allowed values. Although relatively straightforward, I cannot wrap around my head as why the below implementation results in some of the expected mappings to fail:

Can you help?
2 months ago

Stephan van Hulst wrote:Agree with Mike. The usual way to go about this is to just use a Map<Status, Collection<Status>>.

Can you tell us more about why a state consists of two statuses, and why you need a multimap of statuses?

Hi, thanks for replying to my message. Generally speaking, i have a list of statuses whose triggers/actions might result in the same final status, but with different properties to be set. I have the following modifications:

When I test it I still have only a subset of unique pairs. Can you please let me know where I am going wrong with the implementation?

Thank you

2 months ago
I have a scenario whereby I need a map where there are duplicate keys and duplicate values. I have created a list first and then I used associatedBy to convert them to a map, however the duplicates issue is not taken into account. Here is my implementation:

Is there a way to make sure that all possible mappings are retained? I would like to avoid using MultiMap, but I do not seem to find any alternative in Kotlin

2 months ago
I have been trying to implement a state machine with Kotlin as part of my SpringBoot application. I have essentially the following:

  • 1
  • a State class containing all the states

  • 2
  • a Trigger Class (action that triggers a change of state)

  • 3
  • a Transition class that essentially takes an initial state, action and final state

  • 4
  • and a TransitionConfiguration holding all allowed transitions

    I am struggling with writing the actual state machine class. Since it is part of my SpringBoot app and I need to be able to get hold of the entity/dto will be inside my service, however I am not sure how to go about. In particular, I am not sure how to write the method, which is what it should actually apply the state change. Can you help? Can you provide any indication of what that would look like?

    Thank you

    2 months ago

    Tim Holloway wrote:Well, you wouldn't use JAXB. I used it because in my particular app I was working with XML.

    As for the rest, a second glance seems to indicate that you're extending the PostgreSQL Dialect module but possibly not connecting to the extended version. What I'd do in a case like this is set a debugger breakpoint on the "get" method of org.hibernate.dialect.TypeNames and see what it's actually looking at to get the type names. You should be able to pull the Hibernate source and connect it to your debugger with only a little amount of effort - just make sure that the version of the source you pull matches the version of Hibernate that you are using!

    Thank you for this, I had a good dig about it. First of all, here are some relevant info regarding postgres, hibernate and postgres JDBC, etc:

    PostgreSQL JDBC Driver JDBC 4.2 » 42.2.8

    I am going to try to have the hibernate type approach working (namely Approach 2). I have re-aligned the custom Dialect class to my postgres version:

    In my entity I have:

    with this too:

    I then embarked in debugging as per your advice and targeting this from

    Needless to say that I am still getting the same error, but this is what I can see:

    I cannot see jsonb type, but then I want to find out exactly what is the mapping coming from my custom dialect. This is what I can see:

    Not sure where this is going all wrong. It looks very straightforward from and from the posts by the hibernate-types' author.

    If you have any idea, please let me know.

    Tim Holloway wrote:Well, that's way more than my bleary eyes can take in (at least when I'm not being paid for it), but if I'm not mistaken you're coming up against a situation where a database offers features above and beyond standard SQL and JDBC and you're hoping to get Hibernate to integrate tightly with it.

    While I'm certainly a PostgreSQL fan, I do tend to shy away from stuff that's overly vendor-dependent myself.

    In the general realm of JSON versus Hibernate, however, here's a thought. Hibernate JPA works with POJOs. Java also has the ability to serialize JavaScript into and out of POJOs. It's entirely permissible to annotate and/or use POJOs for more than one framework, and in fact I've done so - in my case with JAXB and Hibernate to provide XML support. Just remember to detach/re-attach from JPA when necessary.

    I apologize if I'm babbling or missing that you've already considered that, but, as I said, I'm doing a very superficial reading and wanted to make sure that you had considered that option.

    Hi, thank you for your reply and no need to apologise. Apologies for the verbose post, but I tend to be very specific when I go out and ask the community, so I have provided as much details as possible. I am not sure why I should be considering JAXB, the issue is with mapping from Pojo to Jonsb data type (in Postgres) when using Hibernate + Spring JPA (Jackson is already used for serialising and deserialising). There are 2 main approaches (as i have documented) and still both give me the same error. I simply wonder whether I am missing something very crucial out.

    I have been consulting a number of approaches/posts/questions in order to deal with the following error (full stack trace) when running a Kotlin/SpringBoot application:

    The issue lies in mapping the PostgreSQL’s JSONB data type with Hibernate.

    The 2 approaches I have extensively tried and debugged are the following:

  • 1
  • Implementing a Custom Hibernate Mapping and creating a custom UserType for JSONB. References:,,
  • 2
  • Use Hibernate types. References are,,,

    I have attempted profusely at both, but with no luck whatsoever and I am keen to understand where I am going wrong and what I have been missing.

    Approach 1

    My Entity:

    My PoJO (or basically what it will need to be mapped):

    My custom type (abstract class)

    My concrete class:

    My application.yml jpa hibernate properties

    Approach 2

    Hibernate properties are exactly the same as well as the PoJo class, no custom mapper is included.


    Custom Dialect (using hibernate types):

    Please note that I also tried using only:

    as well as having all this in my entity or the base entity it extended from (no change for that matter):

    Is there anything evidently wrong I am doing in both approaches? I cannot get it working and, not sure if in any way relevant, the numerical value after No Dialect mapping for JDBC type: is always different. I am adding this as I have seen some ids being relevant for certain categories of errors.

    Can you help? Do I need to add additional changes such as a scalar query?

    Thank you
    I am still struggling with the issue and I do not seem to have found a solution.

    I have modified my custom Dialect implementation:

    but I am still getting the very same error. From, it is given multiple options to address the issue and I went for "Mapping the JDBC Types.OTHER to JsonNodeBinaryType at the Dialect level", but shall I also modify my repository? And if so, how? Shall I also do it at the NativeQuery level?

    Thank you
    5 months ago

    Dave Tolls wrote:Can you post the full exception?
    That will give the details of the should have the class name and the field it's having issues with.

    Dave Tolls wrote:Can you post the full exception?
    That will give the details of the should have the class name and the field it's having issues with.

    thank you for your reply. In the meantime, I have changed my approach and went for this:

    after a conversation here:

    in a nutshell, I have removed the custom type implementation.

    Here is my implementation:



    Custom dialect extension

    please note that the same error is shown when passing simply "jsnob" instead of

    That custom class is then referenced in the application.yml:

    Here is the full stacktrace:

    2020-04-21 14:09:13.793 ERROR 41235 --- [  restartedMain] o.s.boot.SpringApplication               : Application run failed

    I seem to have followed all the steps and still I am getting the same No Dialect issue. Am i missing anything?

    Thank you
    5 months ago

    I have been working with a Kotlin/SpringBoot application and I have ran across the following error:

    "No Dialect mapping for JDBC type"

    In simple terms, my app includes the following:

    - Entity class where one of the field is of JSON type (more details to follow)
    - Model entity
    - an Interface called Event whose implementation is then in two classes (signifying different event types/tokens). This is where I think the issue is as I am trying to map a field to an interface, but more to follow in terms of details.

    I have consulted a variety of sources with different approaches:

    I have ended up creating a custom jsonb mapper along these lines:

    In a nutshell, the solution involves:

    - Register custom PostgreSQL95Dialect which has jsonb type
    - Implement Hibernate's UserTypeinterface with custom mapping
    - Annotate Entity with @TypeDef of custom implementation

    Here is my actual implementation:


    The implementation of the Event interface looks like this:

    MyJsonCustomType is my custom implementation of Hibernate's UserType interface with custom mapping. I am not posting all, but just an excerpt:

    My Event interface is as follow:

    While the Dto/model looks like this:

    And here is the custom PostgreSQL95Dialect implementation:

    I am not getting "No Dialect mapping for JDBC type" anylonger, however I am not getting the following:

    "Unable to build Hibernate SessionFactory; nested exception is org.hibernate.MappingException: property mapping has wrong number of columns:"

    Can you help? Where am I going wrong? is the issue down to the fact that I am passing in the entity and dto the interface itself and not the concrete class?

    5 months ago
    I have been working with a Kotlin SpringBoot application and dealing with some API Versioning approach (URI in my case at the moment). Is it good practice to have different version of the same entity in the same data class?

    Thank you
    5 months ago
    I have been working with a Kotlin/SpringBoot and opted for the URI API Versioning approach. I am, however, very unsure on how to go about versioning model, DTO, repository and service classes. What is the best approach to follow. I give you an example from my controller:

    As you can see, I have two @GetMapping with two versions of the service method getCustomers (V1 and V2). I also have a change in the model (one additional field), so I have created a new version of CustomerDto (v2). Is this the correct approach? Change in the model also required me to modify the Dto converter as well as the Repository. Is it good norm to have multiple versions of the repository considering that there has been a change in the model?
    5 months ago
    Thank you for your reply, once again It makes sense and I see your point. I wanted to ask another question, this one is more high level one. When you do versioning, do you simply have multiple versions of your controllers? What about if the underlying model representation changes, would you recommend to have different versions of the model and or dto?

    Thank you,

    6 months ago