-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Optional parameter - database creation
PostPosted: Thu Mar 22, 2007 1:18 pm 
Newbie

Joined: Sun Mar 18, 2007 9:14 am
Posts: 4
I would like to define a @ManyToOne relationship with optional parameter.(eg wordtype below)
I use spring 2.0.3 with Hibernate 3.2.2 GA with JPA, PostgreSQL 8.1.

When the database created automatically the table contains not null constraints however I have defined the field as optional(can be null).
It is the same case if I use @OneToOne.

Is it a bug or I have made any mistake?

My entity definition:

public class DictionaryWord extends BaseEntity {

@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
@Column(name = "id", columnDefinition = "NUMERIC(18) NOT NULL")
private Long id;

@Column(nullable=false)
private String dictionaryWord;

@ManyToOne(optional = true)
@JoinColumn(nullable=true)
private WordType wordtype=null;
}


@Entity
public class WordType extends BaseEntity {

@Id
@Column(name = "code", columnDefinition = "VARCHAR(20) NOT NULL")
private String code;

@Column(nullable=false)
private String wordTypeName;
}


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 22, 2007 4:57 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
It does not behave like that for me

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.