Total members 10262 | Gratitudes |It is currently Wed May 23, 2012 9:19 pm Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 1 post ] 
Author Code Snippet
 Code subject: column can't be null
PostPosted: Tue Apr 20, 2010 2:30 pm 
Offline
Mastermind
User avatar

Joined: Tue Mar 27, 2007 10:55 pm
Posts: 2279
Location: Earth
Has thanked: 39 time
Have thanks: 61 time

If you want to specify that a column can't take no value ( null ) ,you will need to add (nullable=false) attribute in the @Column annotation.

Code:

package com
.codemiles.jpa;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;

@
Entity
@Table(name="BED")
public class Bed implements java.io.Serializable{
    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    @Id
    private String Id
;
    private String type;
    private Date production_date;
    private String width;
    private String height;
    @OneToOne
    
@PrimaryKeyJoinColumn
    private Person person
;
    public String getId() {
        return Id;
    }
    public void setId(String id) {
        Id = id;
    }
     
    
@Column(name="TYPE" ,nullable=false)
    public String getType() {
        return type;
    }
    
    public void setType
(String type) {
        this.type = type;
    }
    @Column(name="PRODUCTION")
    public Date getProduction_date() {
        return production_date;
    }
    public void setProduction_date(Date production_date) {
        this.production_date = production_date;
    }
    @Column(name="WIDTH")
    public String getWidth() {
        return width;
    }
    public void setWidth(String width) {
        this.width = width;
    }
    @Column(name="HEIGHT")
    public String getHeight() {
        return height;
    }
    public void setHeight(String height) {
        this.height = height;
    }
    public void setPerson(Person person) {
    this.person = person;
    }
    public Person getPerson() {
    return person;
    }
    
    
}
 

_________________
Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )


TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 1 post ] 
Quick reply


  

 Similar topics
 Create auto numbered column in mysql query
 Join Column by Primary Key
 Is null a keyword
 Get table column flag in php
 Get column alias in php

All times are UTC [ DST ]


Users browsing similar codes

Users browsing this forum: No registered users and 2 guests



Jump to:  
Previous Code Snippet | Next Code Snippet 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team