Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!

Mason Wyatt

+ Follow
since Jan 26, 2019
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 Mason Wyatt

I have an issue occur in my work project, the problem is Hibernate won't update my child entity when I update it from the View.

my code parent class is:

My child class is :

My controller is

3 months ago
I am working on a small project but very important one for school, and I want to link my public database to the software using jdbc. I am getting connection error to the database!

I have started my project in localhost and it worked just fine.

PS: I am using, also, mysql-connector-java-8.0.15.jar and Hibernate.

I am using this method for the connection:

I can't show you the host ofc but I'll provide the format that I used and I am sure that it is the correct format.

I am excepting a normal connection to the database but, unfortunately, I can't!
1 year ago
Well, I'm working on a library where I need to create a JPA reference of some serialized entity objects.

The time I need to create the entity reference I don't have the ID field value so I somehow first need to create the proxy and then set the id. So I cannot use the

Do you guys have any suggestions?
1 year ago

I am expecting a large json data in my request. And I need to parse that in java. I need to decide the json structure based on the parsing performance. Below are 2 json structure:

   Json Object

   Json Array

Thanks in advance
1 year ago
I have a matrix that represents a grid and would like to find out all possible places an object can move to.

An object can only move horizontally or vertically.

Let's assume that the example below is the grid I'm looking at, which is represented as a 2d matrix. The object is the *, the 0s are empty spaces that an object can move to, and the 1s are walls which the object cannot jump over or go on to.

What is the best way to find all possible movements of this object provided that it can only move horizontally or vertically?

I'd like to print a message saying: "There are 9 places the object can go to." The 9 is for the example below, but I would like it to work for any configuration of the below grid. So all I have to do is give the current coordinates of the * and it will give me the number of possible positions it can move to.

A thing to note is that the *'s original position is not considered in the calculations, which is why for the example below the message would print 9 and not 10.

I have a isaWall method that tells me if the cell is a wall or not. The isaWall method is in a Cell class. Each cell is represented by its coordinates. I looked into using Algorithms like BFS or DFS, but I didn't quite understand how to implement them in this case, as I am not too familiar with the algorithms. I thought of using the Cells as nodes of the graph, but wasn't too sure how to traverse the graph because from the examples I saw online of BFS and DFS, you would usually have a destination node and source node (the source being the position of the *), but I don't really have a destination node in this case. I would really appreciate some help.

1 year ago
I'm trying to verify if all the elements in an array list are same or not. This is my code:

1 year ago
I am building chat application and I want a table - chats and another - messages. Chat will have many messages, also id and user_first and user_second. Right now I am doing it with a composite primary key where the composite is user_first and user_second and the id is unique auto-increment:

is there any better way to do it and why?
I have the hql query that I am executing but receive an error that I don't really understand the cause of.

This is my code:

I get his error on the webpage when trying to execute it:

And also this console error:

1 year ago
I have 2 @RequestParam parameters in my Controller. I want to set the Required value of both the parameters based on a Condition. The condition could be like, if one of the parameter is passed, the other has to passed. So set the required of other as true and vice-versa. Otherwise set both false if none of the parameters are passed.

The syntax of using the variable name inside @RequestParam() is wrong, but I wanted to explain what I want.
1 year ago

I currently have a Many to Many relationship between Events and Users. The auto generated table in my DB called event_registrations keeps track of the relationship and which user goes to which event based on their ids.

What I want to do is have a controller method that takes in an Event id together with a list of user IDs so that the given users get removed from the given event.

Here are my model classes:

What I've tried so far in the EventController:

This runs without problems but the the entries still exist in the join table afterwards. When debugging this, the users do get deleted from the Event object but the changes don't get persisted to the database.

Any help is appreciated!
1 year ago
Simple scenario: AdmisRejet can be linked to a Admis or a PreCandidat.
   2.Admis and PreCandidat can have many AdmisRejet.

All was working when I only had Admis and AdmisRejet.

But then I add PreCandidat (the same way as Admis), I get an hibernate error.

Can't find out why...

Model (they all have getters and setters and ids):


   Caused by: org.hibernate.AnnotationException: @OneToOne or @ManyToOne on nc.unc.importparcoursup.dao.admisDAO.AdmisRejet.preCandidatRejet references an unknown entity: nc.unc.importparcoursup.dao.pgiCocktailDAO.entity.PreCandidat
1 year ago