Not null entity fields

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Not null entity fields

Michael Imhof
<entity entity-name="ArchiveIndex"
            package-name="org.ofbiz.archive"
            title="ArchiveIndex Entity">
      <field name="id" type="id-num"></field>
      <field name="name" type="name"></field>
      <prim-key field="ariSeqnr"/>
    </entity>

How can I make the field <name> a not nullable database field (like primary keys)??

Regards
Michael
Reply | Threaded
Open this post in threaded view
|

Re: Not null entity fields

cjhowe
your type attribute controls this.

id-ne, id-long-ne,id-vlong-ne are the three fieldtypes that are
"isNotEmpty" in the OOTB fieldtype*.xml (ie fieldtypemysql.xml) file.
You are free to add additional fields for the fieldtype*.xml file for
the database you're using.

ofbizhome/framework/entity/fieldtype/fieldtype*.xml

--- Immi <[hidden email]> wrote:

>
> <entity entity-name="ArchiveIndex"
>             package-name="org.ofbiz.archive"
>             title="ArchiveIndex Entity">
>       <field name="id" type="id-num"></field>
>       <field name="name" type="name"></field>
>       <prim-key field="ariSeqnr"/>
>     </entity>
>
> How can I make the field <name> a not nullable database field (like
> primary
> keys)??
>
> Regards
> Michael
> --
> View this message in context:
> http://www.nabble.com/Not-null-entity-fields-tf3180536.html#a8825650
> Sent from the OFBiz - User mailing list archive at Nabble.com.
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Not null entity fields

Michael Imhof
I tried to add "isNotEmpty", dropped the table and restarted ofbiz. But the fields are still nullable.

Here the field I added in the fieldtypemysql.xml:
  <field-type-def type="status" sql-type="VARCHAR(3)" java-type="String">
      <validate method="isNotEmpty" />
  </field-type-def>

I think the NOT NULL declaration of the id fields is set over the primary key declaration:
<prim-key field="id"/>

Regards,
Michael


cjhowe wrote
your type attribute controls this.

id-ne, id-long-ne,id-vlong-ne are the three fieldtypes that are
"isNotEmpty" in the OOTB fieldtype*.xml (ie fieldtypemysql.xml) file.
You are free to add additional fields for the fieldtype*.xml file for
the database you're using.

ofbizhome/framework/entity/fieldtype/fieldtype*.xml

--- Immi <michael.imhof@nowhow.ch> wrote:

>
> <entity entity-name="ArchiveIndex"
>             package-name="org.ofbiz.archive"
>             title="ArchiveIndex Entity">
>       <field name="id" type="id-num"></field>
>       <field name="name" type="name"></field>
>       <prim-key field="ariSeqnr"/>
>     </entity>
>
> How can I make the field <name> a not nullable database field (like
> primary
> keys)??
>
> Regards
> Michael
> --
> View this message in context:
> http://www.nabble.com/Not-null-entity-fields-tf3180536.html#a8825650
> Sent from the OFBiz - User mailing list archive at Nabble.com.
>
>