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

  • Home
  • SEARCH
  • 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 9270637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:25:11+00:00 2026-06-18T15:25:11+00:00

i have below code snippet in dao String GET_CUSTOMER=SELECT * from customer where custName=:custName

  • 0

i have below code snippet in dao

 String GET_CUSTOMER="SELECT * from customer where custName=:custName"
  Session session = getHibernateUtil().getSession();
  SQLQuery query = session.createSQLQuery(GET_CUSTOMER);

    query.setParameter("custName", custName);
    query.setResultTransformer(Transformers
        .aliasToBean(Customer.class));

    Customer custData = (Customer) query
        .uniqueResult();//line

Customer table has some int columns for which some values as null. Now at line1 i get error
Null value was assigned to a property of primitive type setter of Customer.Address

Is there a way in hibernate/query/Transformer to convert the null values to 0 automatically?
I have just mentioned one table i.e customer but there are various joined table which contains int value as null in various columns so i do
not want to handle in query for each table.

UPDATE:- Customer is not Hibernate entity. It pojo with instance fields of int type

  • 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-18T15:25:13+00:00Added an answer on June 18, 2026 at 3:25 pm

    Customer table has some int columns for which some values as null.

    In that case I’d recommend making them Integer fields instead. While you could probably get Hibernate to coalesce NULL to 0 (although possibly not in an easy global manner), it’s not really mapping your data effectively – why would you want to lose information like that?

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

Sidebar

Related Questions

I have below code snippet SimpleDateFormat dateFormat = new SimpleDateFormat( yyyy-MM-dd hh:mm:ss.SSS); String processedContentDate=2012-04-10
i have below code snippet in jsp <HTML> <BODY> <select id=customerIds onchange=doOperation()> <option value=default>
I have below snippet of code in which TestClass is extending jPanel which is
I have this snippet of code below. I want to pass the value of
I have a code snippet as below <CheckBox Name=cb Margin=1,2,1,0 IsChecked={Binding Path=IsManager} IsEnabled=True/> Consider
Below is the snippet of my code. I have a JTable. I have extended
I have below code: class Program { static void Main(string[] args) { Task[] tasks
I have below code behind in c# if (Session[cmpDictionaryTitle]!= null) { downloadLinks.Text += @<li><a
I have below code snippet and this works fine. Shouldn't it throw compile time
I have below a code snippet where content inside #FirstDiv gets appended at runtime

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.