Is there a way to smoothly run side-by-side projects, each using different Java versions, in IntelliJ (v2022.x+)? For instance, I am using IntelliJ to work on two projects. One project is in Java 11 and the other is in Java 17 – each project has its own IDE instance. Each project is configured to use th…
Tag: java
How does parameters of a method get stored in stack during a recursive call?
I was doing a leetcode question https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree-ii/ and I am confused on how parameters for a method get stored during a recursive call. If a node gets visited, I wanted to save it’s state that it was visited. When I send two variables, when the stac…
Sort a List of objects based in its Sublist method size
I’m trying to make my own “Facebook reaction bar” and I got into a problem, I need to sort a list of objects based in its sublist method size, let me explain! I have a ReactionModel which has a property “usernames” which is a List of Strings of usernames of those users that used …
Spring SQL: org.h2.jdbc.JdbcSQLSyntaxErrorException: Syntax error in SQL statement “; expected “identifier”, when using INSERT INTO
I am working on a Spring Web Application. I am using mysql database, but for my unit tests, I want to run them in H2 database. Test specific application properties: As you can see, my database is in MODE=MYSQL, since my data.sql is in MySQL dialect. But during initialization of of data.sql I get this error: I…
String input of weekdays in German to Localdate
I have a string input of weekdays in German and need to get the next Localdate after today which corresponds to the given weekday string. If for example the input is Montag (Monday) I need the output as Localdate of 2022-05-16 which is the next Monday after today. If the input was in english I could do someth…
Using Optionals correctly in service layer of spring boot application
I new to spring boot application development. I using service layer in my application, but came across the repository method that return Optional as shown below. My question is , whether I am using the Optional correctly here. And is it ok to check this optional (isPresent()) in the RestController and through…
Null pointer exception while running selenium test. I am using Page object model
Below is my Testbase class: My VerifyLaydownlogintest as below: And this is my Login page class: This is error of NPE: I tried to resolve this but unable to find the root cause. Where am I going wrong? My config.properties Answer You are using TestNG as your test automation framework. In TestNG, execution wil…
Return link from Hateos
I have this old Spring Hateos code which I want to migrate to the latest version: I tried this: I get error at this line: Can you advise what is the correct way to implement this? Answer Based on your comments & question for migration this is what I am suggesting: …. //calling addLinlk And inside ad…
Overriding transaction propagation levels for methods having Spring’s @transactional
I have multiple methods in my codebase annotated with Spring’s @transactional with different propgation levels (lets ignore the idea behind choosing the propagation levels). Example – Now I have a new use case where I want to perform all these operations in a single transaction (for this specific …