Jump to content

[JAVA] "?" values when .persist(object) in H2 in memory database

shooter27
Go to solution Solved by shooter27,

Hi, I'm having trouble saving objects in my in memory h2 database (using hibernate)

I checked and my entityManager is correct, it starts the transaction, tries to persist the object, commit the transaction (or rollback if an exception is throws)

Now, I dont understant why, when I look in the console, as soon as I persist the object, I get this:

image.png.daa8b4c437bcbbcc03549620fcad03b7.png

 

Entity:

image.png.4d62053a434e0edf9d5dd7eff12536f7.png

 

In repository:

image.png.c5c16855a2aa8534cd5921c97fce87cd.png

Content of object to persist:

image.png.cea536444436e0f06442489b9c96769b.png

 

I've been trying to figure this out for a couple hours but nothing seems to fix it, what dis I do wrong?

Hi, I'm having trouble saving objects in my in memory h2 database (using hibernate)

I checked and my entityManager is correct, it starts the transaction, tries to persist the object, commit the transaction (or rollback if an exception is throws)

Now, I dont understant why, when I look in the console, as soon as I persist the object, I get this:

image.png.daa8b4c437bcbbcc03549620fcad03b7.png

 

Entity:

image.png.4d62053a434e0edf9d5dd7eff12536f7.png

 

In repository:

image.png.c5c16855a2aa8534cd5921c97fce87cd.png

Content of object to persist:

image.png.cea536444436e0f06442489b9c96769b.png

 

I've been trying to figure this out for a couple hours but nothing seems to fix it, what dis I do wrong?

Link to comment
Share on other sites

Link to post
Share on other sites

You need to set logging level to trace to see the query parameters. 

 

log4j.logger.org.hibernate.type=trace

This is for log4j, change org.hibernate.type to trace for whatever logging library you're using

Link to comment
Share on other sites

Link to post
Share on other sites

42 minutes ago, elpiop said:

You need to set logging level to trace to see the query parameters. 

 


log4j.logger.org.hibernate.type=trace

This is for log4j, change org.hibernate.type to trace for whatever logging library you're using

I found my error actually, in the console, hibernete doesn't show the inserted value, it maks parameters as "?". It was working all along, I just did not know it.

Link to comment
Share on other sites

Link to post
Share on other sites

4 hours ago, elpiop said:

You need to set logging level to trace to see the query parameters. 

 


log4j.logger.org.hibernate.type=trace

This is for log4j, change org.hibernate.type to trace for whatever logging library you're using

would you by any chance know how I can map an entity property to a non-entity property (which is the column value) without creating join tables?
I need the appointmentNumber (which is a string (varchar in DB)) to be mapped to this
image.png.24d36349f620647b83046d83d5bf1788.png
here's the non-entoty that I want to map with on the number property
image.png.461ccc187e44a945d6b7c8359147bb5a.png
 

I got it working with @Embeddable and @Embedded annotations but it creates a join table which I can't have

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×