#SPRING BOOT

146 messages · Page 1 of 1 (latest)

fast dew
#

So this application should be really simple, but for some reasons it is not working this simple CRUD, which "Passagens" (tickets) hava a onetoone relationship with aeroportos(airports) whtich is fine, but then when i move on to the front i created a dropdown and foreach to list all the airports and select the name of the correspondent airport and the id, when i finally move to the front it says that some of the values arent' being completed cuz they are all not nullable. BUT I CHECKED SOO MUCH, i think the issue is how do I pick the foreign of airports in the front and insert in the table of passagens(tickets) THE OTHERS TABLES ARE WORKING JUST FINEEE! AND CRUD ARE WORKING FOR THEM!

ember basinBOT
#

This post has been reserved for your question.

Hey @fast dew! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

scenic pilot
#

Can you set a breakpoint in the cadastrar method?

#

in the controller

#

and check the content of the Passagens model attribute

#

maybe one of these dates is null?

fast dew
#

Great idea daniel

#

like this?

scenic pilot
#

yes

ember basinBOT
scenic pilot
fast dew
#

ohhh thanks let me see i know how to set the breakpoint and trigger but idk how to enter springboot eclipse in debug mode

ember basinBOT
fast dew
#

let me read

scenic pilot
# ember basin

Disclaimer: I was a slightly involved in the creation/review of the dev.java article

scenic pilot
#

normally there's a green play button for running the application

fast dew
#

find it!!!

scenic pilot
#

there should be a green bug next to it

#

yeah

fast dew
#

now is launching hehee lets see

scenic pilot
#

if it's started in debug mode, it will stop at breakpoints

scenic pilot
# ember basin

but the sites linked here explain debugging both in general and in Eclipse specifically

fast dew
scenic pilot
#

switch

#

is the @DateTimeFormat from jackson?

fast dew
scenic pilot
#

on the right in the variables view, you can see your variables

#

specifically passagem

#

Is that as you expect it?

fast dew
#

the id values are fine

#

and it actuallys show the airport id right?

#

soo maybe

#

the problem it is the date

scenic pilot
#

what is the chegada thing?

fast dew
#

oh date of returning

scenic pilot
fast dew
#

not nullabe

#

all the models not nullable values

#

even the ids

scenic pilot
#

yes but is it null in the debugger?

#

it's not nullable for the DB

fast dew
#

perfect

#

all three are null

#

you GOT IT

#

all three dates null

#

but preco(price) is working just fine

scenic pilot
#

the error tells you "it tried to put a non nullable field (the chefeda thing) into the database but it was null

fast dew
#

and nome name too

#

yeah

#

which is weird cuz the inputs are fine right

scenic pilot
fast dew
#

what is jackson

scenic pilot
#

a json thing

#

I think converting the inputs to Dates could be an issue

fast dew
#

mport java.util.Date;

import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.format.annotation.DateTimeFormat.ISO;

scenic pilot
#

since these are typically sent as strings

scenic pilot
#

Can you check the network tab of the browser window while you make the request

fast dew
#

you the boss let me do it

scenic pilot
#

browser devtools*

#

the network tab shows you exactly what is being sent

#

that should match what the Spring application receives

fast dew
#

cadastrar means create

#

the create method

scenic pilot
#

click on it

#

btw you can press F8 in Eclipse and it will continue

#

like the breakpoint suspends the program

fast dew
scenic pilot
#

and F8 lets it continue

fast dew
#

i clicked

#

and then i receiveid that

scenic pilot
scenic pilot
fast dew
#

reload and see the network?

scenic pilot
# fast dew

that one looks like you might have reloaded the page by clicking in the URL bar and pressing enter or similar

#

Do you know the difference between GET and POST?

fast dew
#

lil bit get

#

i can just receive the value cannot change it

#

post and can change the entire thing

scenic pilot
fast dew
#

like for instance i can get the id

scenic pilot
#

the network tab should show you what's sent

fast dew
#

but i cant change the id in GET

scenic pilot
#

ah so the browser can do GET and POST requests

fast dew
scenic pilot
#

typically, you'd use GET for anything requesting a page and POST for operations that change something

scenic pilot
# fast dew

now click on the submit button and record the request in the network tab

fast dew
scenic pilot
#

or the other parts there

#

these might give you information about the request

fast dew
#

wow

scenic pilot
fast dew
#

yeah you right but we i was doing okay it wasnt working soo

#

let me try again

scenic pilot
fast dew
#

nop

scenic pilot
#

still same error?

#

with the null thing

fast dew
#

yes...

#

let me enter the debug again

scenic pilot
#

I think you should use th:field for your thymeleaf fields

fast dew
scenic pilot
#

in the inputs

fast dew
#

but like for creating the value should be "" right?

scenic pilot
#

?

fast dew
#

i mean for price it is like that and price is working

#

should i change for date

scenic pilot
#

idk

scenic pilot
fast dew
#

i will try sir!

#

lets see

scenic pilot
#

you could also try enabling verbose logging

fast dew
#

for the dates

fast dew
scenic pilot
scenic pilot
#

whenever something happens

scenic pilot
fast dew
#

what about this

#

it could bee

#

i would need to drop the bd right

fast dew
#

Daniel

#

big news

#

changed tot ype string and the error persists

#

lol

ember basinBOT
#

💤 Post marked as dormant

This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping.
Warning: abusing this will result in moderative actions taken against you.

scenic pilot
#

maybe the issue is the variables being multiple words

scenic pilot
#

but in general, I would try to use LocalDate or LocalDateTime if possible

fast dew
#

Thanks soo much for you helping tho

ember basinBOT
# fast dew Thanks soo much for you helping tho

If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.

fast dew
#

you explain step by step

#

and didnt call me stupid

#

even tho i m newbie

#

we need more people like you in the community