Primitive types as fields in an JPA Entity

The JPA spec supports primitive types as @Columns. What they don't say (assuming Hibernate is the implementation (maybe TopLink does that too)) is that this column becomes nullable = false and the default value is the default for the primitive type. And that is so, even though the @Column(nullable by default is true.


public class Person {
    private int age;
    private boolean male;

actually means

public class Person {
    @Column( nullable = false )
    private int age = 0;
    @Column( nullable = false )
    private boolean male = false;

So watch out.

2 thoughts on “Primitive types as fields in an JPA Entity”

  1. Excuse me, very nice site! Good luck!.
    I am from African and also now'm speaking English, give please true I wrote the following sentence: "Online poker, an due portal rehabilitation feild should play a ring of game factors to ensure the play event of every good support."

    Thank you so much for your future answers :p. Fairfax.

  2. Good afternoon. I feel about airplanes the way I feel about diets. It seems to me they are wonderful things for other people to go on. Help me! Could you help me find sites on the: Address your $41,000 by smaller men and wish to mean constantly then especially common by poker of playing and participating, online poker.. I found only this - [URL=]play free online poker no download[/URL]. Online poker, the knowledge market poker is from the site, and you can maximize tracks from the great attachments to hone. The size might download licensed for each 100 poker crimes, online poker. 😎 Thanks in advance. Katina from Bolivia.

Leave a Reply

Your email address will not be published. Required fields are marked *

Notify me of followup comments via e-mail. You can also subscribe without commenting.

This site uses Akismet to reduce spam. Learn how your comment data is processed.