It would be best to create your own custom field type file, then reference it in your MySQL data source. Leave the original MySQL field type file as-is.

I too have noticed problems getting ModelInduceFromDb to work properly with MySQL. Maybe once you get this working you can create a Jira issue for it.

Adrian Crum
Sandglass Software
www.sandglass-software.com

On 12/20/2014 8:25 AM, i...@agentur-m3.de wrote:
Thank you all for your help with understanding the
datasource and delegator concepts!

There is one additional point to this topic in the
context of automatic importing the entities (it would
be great if this connection would work at the end!):

in ModelInduceFromDb there seems to be a problem
with with the field-names of the mysql definitions.

I work with mysql server version 5.6.20 (as part of xampp).
For some of the field definitions ofbiz does not seem
to have appropriate fieldtypes, so that some of the
results of calling the servlet:

https://localhost:8443/webtools/control/view/ModelInduceFromDb

are like this:
<field name="postParent" type="invalid-BIGINT UNSIGNED:20:0"></field>

So they are invalid and of course they cause errors when using them as
entity-defintions.

Then I took a look at the fieldtype-definitions and to me it seems
that some of the valid mysql-fieldtypes  are not defined in
fieldtypemysql.xml.

Here are the complete fields for a table (wpposts form wordpress) I
would like to import for testing. The reference wordpress schema(1),
the ofbiz fieldtypes(2) and the ModelInduceFromDb-result (3):


(1) This is the reference field list from the mysql table:

   ID bigint(20) unsigned NOT NULL auto_increment,
   post_author bigint(20) unsigned NOT NULL default '0',
   post_date datetime NOT NULL default '0000-00-00 00:00:00',
   post_date_gmt datetime NOT NULL default '0000-00-00 00:00:00',
   post_content longtext NOT NULL,
   post_title text NOT NULL,
   post_excerpt text NOT NULL,
   post_status varchar(20) NOT NULL default 'publish',
   comment_status varchar(20) NOT NULL default 'open',
   ping_status varchar(20) NOT NULL default 'open',
   post_password varchar(20) NOT NULL default '',
   post_name varchar(200) NOT NULL default '',
   to_ping text NOT NULL,
   pinged text NOT NULL,
   post_modified datetime NOT NULL default '0000-00-00 00:00:00',
   post_modified_gmt datetime NOT NULL default '0000-00-00 00:00:00',
   post_content_filtered longtext NOT NULL,
   post_parent bigint(20) unsigned NOT NULL default '0',
   guid varchar(255) NOT NULL default '',
   menu_order int(11) NOT NULL default '0',
   post_type varchar(20) NOT NULL default 'post',
   post_mime_type varchar(100) NOT NULL default '',
   comment_count bigint(20) NOT NULL default '0',
   PRIMARY KEY  (ID),
   KEY post_name (post_name),
   KEY type_status_date (post_type,post_status,post_date,ID),
   KEY post_parent (post_parent),
   KEY post_author (post_author)


(2) This is ofbiz's framework/entity/fieldtype/fieldtypemysql.xml content:


<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
-->

<fieldtypemodel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";

xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/fieldtypemodel.xsd";>
   <!-- ===================== field-type-def ==================== -->
     <!-- General Types -->
     <field-type-def type="blob" sql-type="LONGBLOB"
java-type="java.sql.Blob"/>
     <field-type-def type="byte-array" sql-type="LONGBLOB"
java-type="byte[]"/>
     <field-type-def type="object" sql-type="LONGBLOB" java-type="Object"/>

     <field-type-def type="date-time" sql-type="DATETIME"
java-type="java.sql.Timestamp"/>
     <field-type-def type="date" sql-type="DATE" java-type="java.sql.Date"/>
     <field-type-def type="time" sql-type="TIME" java-type="java.sql.Time"/>

     <field-type-def type="currency-amount" sql-type="DECIMAL(18,2)"
java-type="java.math.BigDecimal"/>
     <field-type-def type="currency-precise" sql-type="DECIMAL(18,3)"
java-type="java.math.BigDecimal"/>
     <field-type-def type="fixed-point" sql-type="DECIMAL(18,6)"
java-type="java.math.BigDecimal"/>
     <field-type-def type="floating-point" sql-type="DOUBLE"
java-type="Double"/>
     <field-type-def type="numeric" sql-type="DECIMAL(20,0)"
java-type="Long"/>

     <field-type-def type="id" sql-type="VARCHAR(20)" java-type="String"/>
     <field-type-def type="id-long" sql-type="VARCHAR(60)"
java-type="String"/>
     <field-type-def type="id-vlong" sql-type="VARCHAR(250)"
java-type="String"/>

     <field-type-def type="indicator" sql-type="CHAR(1)" java-type="String"/>
     <field-type-def type="very-short" sql-type="VARCHAR(10)"
java-type="String"/>
     <field-type-def type="short-varchar" sql-type="VARCHAR(60)"
java-type="String"/>
     <field-type-def type="long-varchar" sql-type="VARCHAR(255)"
java-type="String"/>
     <field-type-def type="very-long" sql-type="LONGTEXT"
java-type="String"/>

     <field-type-def type="comment" sql-type="VARCHAR(255)"
java-type="String"/>
     <field-type-def type="description" sql-type="VARCHAR(255)"
java-type="String"/>
     <field-type-def type="name" sql-type="VARCHAR(100)" java-type="String"/>
     <field-type-def type="value" sql-type="VARCHAR(255)"
java-type="String"/>

     <!-- Specialized Types -->
     <field-type-def type="credit-card-number" sql-type="VARCHAR(255)"
java-type="String"/>
     <field-type-def type="credit-card-date" sql-type="VARCHAR(20)"
java-type="String"/>
     <field-type-def type="email" sql-type="VARCHAR(255)"
java-type="String"/>
     <field-type-def type="url" sql-type="VARCHAR(255)" java-type="String"/>
     <field-type-def type="id-ne" sql-type="VARCHAR(20)" java-type="String"/>
     <field-type-def type="id-long-ne" sql-type="VARCHAR(60)"
java-type="String"/>
     <field-type-def type="id-vlong-ne" sql-type="VARCHAR(250)"
java-type="String"/>
     <field-type-def type="tel-number" sql-type="VARCHAR(60)"
java-type="String"/>
</fieldtypemodel>


(3) And this is the induced result (ModelInduceFromDb):

  <entity entity-name="WpPosts"
             package-name=""
             title="None"
             copyright="Copyright 2001-2014 The Apache Software Foundation">
       <field name="menuOrder" type="numeric"></field>
       <field name="postModified" type="date-time"></field>
       <field name="postMimeType" type="long-varchar"></field>
       <field name="guid" type="long-varchar"></field>
       <field name="postAuthor" type="invalid-BIGINT UNSIGNED:20:0"></field>
       <field name="postModifiedGmt" type="date-time"></field>
       <field name="postName" type="long-varchar"></field>
       <field name="commentCount" type="invalid-BIGINT:19:0"></field>
       <field name="postDate" type="date-time"></field>
       <field name="postContentFiltered"
type="invalid-LONGTEXT:2147483647:0"></field>
       <field name="pingStatus" type="short-varchar"></field>
       <field name="postParent" type="invalid-BIGINT UNSIGNED:20:0"></field>
       <field name="toPing" type="very-long"></field>
       <field name="postExcerpt" type="very-long"></field>
       <field name="commentStatus" type="short-varchar"></field>
       <field name="pinged" type="very-long"></field>
       <field name="postStatus" type="short-varchar"></field>
       <field name="id" type="invalid-BIGINT UNSIGNED:20:0"></field>
       <field name="postDateGmt" type="date-time"></field>
       <field name="postTitle" type="very-long"></field>
       <field name="postPassword" type="short-varchar"></field>
       <field name="postContent"
type="invalid-LONGTEXT:2147483647:0"></field>
       <field name="postType" type="short-varchar"></field>
     </entity>

Would it solve the problem  to add the missing fieldtypes to
fieldtypedef.xml ?




Reply via email to