Sprign Data JDBC doesnt save my Domain
I have these classes:
This is my schema:
32 Replies
⌛
This post has been reserved for your question.
Hey @Suika! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
I have this test:
but it says:
Caused by: org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [INSERT INTO "antwort" ("antwort", "karteikarte", "karteikarte_key", "karteikarte_set", "karteikarte_set_key") VALUES (?, ?, ?, ?, ?)]
why is it trying to insert something into karteikarte_set and karteikarte_set_key when there is no relation stated?
did you mark the classes as @Entity
oh you arent using jpa right
try adding those fields to the antwort table
see if that helps
What is
KarteikartenSetDto
?do you think it happens cuz theres no field when creating the tables
more like because there's a field that isn't in the DB
possible a field that's in some classes but not others
oh yea i wrote that wrong
Also it would be know what exactly
repository
is - it doesn't seem to be KarteikartenSetDao
oh yea
it looks like it saves the dto
instead of the actual object
in that dao
the test doesn't match that
Also it would be good to see the full stack trace
ping him or something ig
nvm i will
@Suika
hi
sec
the dto is not the problem i think
everything worked when i didnt add List<Antwort> to my Karteikarte class
the dto is to decouple data jdbc annotations from the domain
you have 1:n relation
man the stacktrace is 100 lines
and it's a
List
so the information with set the card belongs to is stored in the card
at least that's what Spring JDBC assumes
so it expects "antwort" to contain a karteikarte_set
referencing the karteikarte_set
and also contain a karteikarte_set
containing the index in the listbut there is no relation bewteen antwort and karteikarte_set
onkly to karteikarte
and it does not show this error here:
its basically the same
test has List<Frage> and Frage has List<Aussage>
i dont get an error that aussage need test_key or something
Why would it?
because its the same schema
im only saving reference to frage
not to test
ah I see
if i have karteikarte_set and karteikarte_set_key, then karteikarteSet would have a List<Antwort>
but doesnt and neednt
*it
Can you show the full test and stack trace?


Can you post it as text?
Is
KarteikartenSetRepositoryImpl
a class you created or is it generated?created
Can you show it?
Can you show your
KarteikartenSetDto
?
as far as i know i would not need a KarteikarteDto
or a AntwortDto
💤
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.