Home Using @Column and @Formula in Hibernate at the same time
Reply: 0

Using @Column and @Formula in Hibernate at the same time

user1154
1#
user1154 Published in July 16, 2018, 6:16 pm

I've got a POJO and currently I'm getting a value from a single column. However, I'm moving to retrieve it using Hibernate @Formula (I select the latest record from another table). I want to go softly in order not to break anything.

So what I want to do is something like this:

class SomeDto {
    private someField;

    @Column("PREVIOUS_FIELD_COLUMN", nullable = false, length = 1)
    @Formula("@NEW RETRIEVING LOGIC@")
    public getSomeField() {
    ...
}

so that I could be able to store the someField value in the PREVIOUS_FIELD_COLUMN and at the same time retrieve the value based on the new criteria.

However now it seems that Hibernate ignores the @Column annotation as I get the following error:

SQLIntegrityConstraintViolationException: ORA-01400: cannot insert NULL into

I see in logs that Hibernate skips PREVIOUS_FIELD_COLUMN in the insert statement being generated (doesn't list it and doesn't set the value from POJO).

Any help appreciated, thank you very much!

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.402036 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO