-->
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: Column 'IP' cannot be null
PostPosted: Wed Jun 15, 2005 8:37 am 
hi,
I'm getting the following error message when i try to insert a line with Nhibrnate:

Code:
could not synchronize database state with session --> Column 'IP' cannot be nul


I've verified that it's due the attribute which is define as "not null" but has no default values.

What can i do to resolve that ?? hav i to modify my mapping file??

This my mappinf file :
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
   <class name="IntMapLib.Interface, IntMapLib" table="Interface">

      <id name="Port" column="Port" type="Int32" length="9">
         <generator class="assigned" />
      </id>
      <property name="Subnet" type="Int16" length="6"/>
      <property name="Domaine" type="String" length="50"/>
      <property name="Dhcp" type="Int16" length="1"/>
      <property name="Ip" column= "IP" type="string" length="15"/>
      <property name="Portsouverts" type="string" length="255"/>
      <property name="Nom" type="String" length="50"/>
      <property name="Dnsprimaire" type="String" length="15"/>
      <property name="Dnssecondaire" type="String" length="15"/>
      <property name="Passerelle" type="String" length="15"/>
      <property name="Masque" type="string" length="15"/>
   </class>
</hibernate-mapping>


And this is my table :

Code:
+---------------+--------------+------+-----+---------+-------+
| Field         | Type         | Null | Key | Default | Extra |
+---------------+--------------+------+-----+---------+-------+
| Port          | int(9)       |      | PRI | 0       |       |
| IP            | varchar(15)  |      | PRI |         |       |
| Masque        | varchar(15)  | YES  |     | NULL    |       |
| PortsOuverts  | varchar(255) | YES  |     | NULL    |       |
| Subnet        | smallint(6)  |      | MUL | -1      |       |
| Nom           | varchar(50)  | YES  |     | NULL    |       |
| Domaine       | varchar(50)  | YES  |     | NULL    |       |
| DHCP          | tinyint(1)   | YES  |     | 1       |       |
| DNSPrimaire   | varchar(15)  | YES  |     | NULL    |       |
| DNSSecondaire | varchar(15)  | YES  |     | NULL    |       |
| Passerelle    | varchar(15)  | YES  |     | NULL    |       |
+---------------+--------------+------+-----+---------+-------+


thank u in advance


Top
  
 
 Post subject: Solution
PostPosted: Wed Jun 15, 2005 9:11 am 
Hi,
It's ok!! I could resolve the problem, i just modified the following line :

Code:
<property name="Ip" column="IP"  type="string" length="15"/>

To

Code:
<property name="Ip" column="IP" not-null="true" type="string" length="15"/>


Regards


Top
  
 
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.