Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7933299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T21:17:20+00:00 2026-06-03T21:17:20+00:00

I have a hibernate-mapped Java object, JKL , which is full of a bunch

  • 0

I have a hibernate-mapped Java object, JKL, which is full of a bunch of normal hibernate-mappable fields (like strings and integers).

I’m added a new embedded field to it (which lives in the same table — not a mapping), asdf, which is a fj.data.Option<ASDF>. I’ve made it an option to make it clear that this field may not actually contain anything (as opposed to having to handle null every time I access it).

How do I set up the mapping in my JKL.hbm.xml file? I’d like hibernate to automatically convert a null in the database to a none of fj.data.Option<ASDF> when it retrieves the object. It should also convert a non-null instance of ASDF to a some of fj.data.Option<ASDF>.

Is there any other trickery that I have to do?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T21:17:22+00:00Added an answer on June 3, 2026 at 9:17 pm

    I would suggest introducing FunctionalJava’s Option in the accessors (getter and setter), while leaving Hibernate to handle a simple java field which is allowed to be null.

    For example, for an optional Integer field:

    // SQL
    CREATE TABLE `JKL` (
        `JKL_ID` INTEGER PRIMARY KEY,
        `MY_FIELD` INTEGER DEFAULT NULL
    )
    

    You can map a Hibernate private field directly:

    // Java
    @Column(nullable = true)
    private Integer myField;
    

    You could then introduce Option at the accessor boundary:

    // Java
    public fj.data.Option<Integer> getMyField() {
        return fj.data.Option.fromNull(myField);
    }
    
    public void setMyField(fj.data.Option<Integer> value) {
        myField = value.toNull();
    }
    

    Does that work for your needs?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table called Person which I have already mapped in hibernate I
We have an object, A, which contains another object, B. We have Hibernate calling
I have an application which uses Hibernate for database transactions, I have mapped all
Let's say I have a class mapped with hibernate, with bunch of properties, an
You may have a bytea column mapped as Hibernate type binary. In java, the
I have a bunch of Hibernate mapped objects in my Spring MVC app. Default
I have mapped several java classes like Customer, Assessment, Rating, ... to a database
I have the following class structure FlowerDAO with the fields (mapped using Hibernate): id
I have the following Hibernate Mapping, which has to be mapped using the Table
I have a class which is mapped to a table using the hibernate notations

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.