microservices-v9 icon indicating copy to clipboard operation
microservices-v9 copied to clipboard

Null not allowed for column **ID

Open MrNocTV opened this issue 6 years ago • 3 comments

I got problems with the default generated strategy GenerationType.AUTO , I add GenerationType.SEQUENCE for

  • ScoreCard.java
  • Multiplication.java
  • MultiplicationResultAttempt.java
  • User.java

then everything works just fine.

Please verify this issue and allow me to create a new PR if my solution is correct.

MrNocTV avatar Sep 12 '19 04:09 MrNocTV

Hi,

Are you using the same library versions as in this repository? Also, please describe exactly what are the problems you're finding.

Thanks!

mechero avatar Sep 20 '19 04:09 mechero

Hi @mechero , The problem is I cannot persist object due to "null pointer exception" with column *ID. I don't think it's due to the difference in version because I already tried using your existing code. Also from this post of thoughts-on-java. We should use GenerationType.SEQUENCE because it's better in term of performance and it will work on all versions of hibernate.

MrNocTV avatar Sep 20 '19 05:09 MrNocTV

I'm not saying it's not better to use it, but I need to comment the code to indicate from which version of [Hibernate / Spring Boot / other libraries] the code doesn't work anymore. Keep in mind that this repo is referenced from a book that is "static" between editions so it needs to be very clear in comments what differs from the edition and why it's been changed.

This was certainly working by the time the book got released so there must be a difference somewhere.

mechero avatar Sep 22 '19 07:09 mechero