Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc) » [Teneo] Switch to DB2 and not getting identity columns
[Teneo] Switch to DB2 and not getting identity columns [message #124960] |
Mon, 02 June 2008 16:18 |
David Wynter Messages: 4624 Registered: July 2009 |
Senior Member |
|
|
Hi,
I was successfully generating a schema on MySQL and getting the auto
increment on the id primary key column. I switched to DB2 dialect and if
I leave the primary key as e_id I do get IDENTITY columns but when I use
id in the model with the annotation I do not get them. Am I missing
something?
Here are my properties
props.setProperty(Environment.DRIVER, "com.ibm.db2.jcc.DB2Driver");
props.setProperty(Environment.USER, "Administrator");
props.setProperty(Environment.PASS, "e*****");
props.setProperty(Environment.URL, "jdbc:db2://192.168.0.3:50000/"
+ dbName);
props.setProperty(Environment.DIALECT,
org.hibernate.dialect.DB2Dialect.class.getName());
props.setProperty(PersistenceOptions.MAXIMUM_SQL_NAME_LENGTH ,
"30");
props.setProperty(PersistenceOptions.ID_FEATURE_AS_PRIMARY_K EY,
"true");
props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME ,
"id");
props.setProperty(PersistenceOptions.JOIN_COLUMN_NAMING_STRA TEGY, "simple");
props.setProperty(PersistenceOptions.ALSO_MAP_AS_CLASS, "false");
props.setProperty(PersistenceOptions.DEFAULT_TEMPORAL_VALUE,
"DATE");
props.setProperty(PersistenceOptions.DISABLE_ECONTAINER_MAPP ING, "true");
props.setProperty(PersistenceOptions.ALWAYS_VERSION, "false");
props.setProperty(PersistenceOptions.ALWAYS_MAP_LIST_AS_BAG,
"true");
props.setProperty(PersistenceOptions.INHERITANCE_MAPPING,
"JOINED");
Here is a sample of the XSD
<xsd:complexType name="Tranche">
<xsd:sequence minOccurs="0" maxOccurs="1">
<xsd:element ref="gensec:source" />
</xsd:sequence>
<xsd:attribute name="id" type="xsd:int">
<xsd:annotation>
<xsd:appinfo source="teneo.jpa">@Id</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute
default="http://www.mddl.org/mddl/scheme/trancheIDType.xml"
name="scheme" use="optional" />
<xsd:attribute name="nameRef" type="xsd:anyURI" />
<xsd:attribute default="valid" name="validity"
type="gensec:QualityEnumeration" use="optional" />
<xsd:attribute name="rank" type="xsd:int" />
</xsd:complexType>
<xsd:element name="tranche" type="gensec:Tranche" />
Thx,
David
|
|
|
Re: [Teneo] Switch to DB2 and not getting identity columns [message #124973 is a reply to message #124960] |
Mon, 02 June 2008 17:09 |
David Wynter Messages: 4624 Registered: July 2009 |
Senior Member |
|
|
Opps, I checked the MySQL and it did not have the auto increment set
either. So when you replace e_id as the primary key which option is
required to get these columns as auto increment?
Thx.
David
david wrote:
> Hi,
>
> I was successfully generating a schema on MySQL and getting the auto
> increment on the id primary key column. I switched to DB2 dialect and if
> I leave the primary key as e_id I do get IDENTITY columns but when I use
> id in the model with the annotation I do not get them. Am I missing
> something?
>
> Here are my properties
>
> props.setProperty(Environment.DRIVER, "com.ibm.db2.jcc.DB2Driver");
> props.setProperty(Environment.USER, "Administrator");
> props.setProperty(Environment.PASS, "e*****");
> props.setProperty(Environment.URL,
> "jdbc:db2://192.168.0.3:50000/" + dbName);
> props.setProperty(Environment.DIALECT,
> org.hibernate.dialect.DB2Dialect.class.getName());
> props.setProperty(PersistenceOptions.MAXIMUM_SQL_NAME_LENGTH ,
> "30");
> props.setProperty(PersistenceOptions.ID_FEATURE_AS_PRIMARY_K EY,
> "true");
> props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME ,
> "id");
>
> props.setProperty(PersistenceOptions.JOIN_COLUMN_NAMING_STRA TEGY,
> "simple");
> props.setProperty(PersistenceOptions.ALSO_MAP_AS_CLASS, "false");
> props.setProperty(PersistenceOptions.DEFAULT_TEMPORAL_VALUE,
> "DATE");
>
> props.setProperty(PersistenceOptions.DISABLE_ECONTAINER_MAPP ING, "true");
> props.setProperty(PersistenceOptions.ALWAYS_VERSION, "false");
> props.setProperty(PersistenceOptions.ALWAYS_MAP_LIST_AS_BAG,
> "true");
> props.setProperty(PersistenceOptions.INHERITANCE_MAPPING,
> "JOINED");
>
> Here is a sample of the XSD
>
> <xsd:complexType name="Tranche">
> <xsd:sequence minOccurs="0" maxOccurs="1">
> <xsd:element ref="gensec:source" />
> </xsd:sequence>
> <xsd:attribute name="id" type="xsd:int">
> <xsd:annotation>
> <xsd:appinfo source="teneo.jpa">@Id</xsd:appinfo>
> </xsd:annotation>
> </xsd:attribute>
> <xsd:attribute
> default="http://www.mddl.org/mddl/scheme/trancheIDType.xml"
> name="scheme" use="optional" />
> <xsd:attribute name="nameRef" type="xsd:anyURI" />
> <xsd:attribute default="valid" name="validity"
> type="gensec:QualityEnumeration" use="optional" />
> <xsd:attribute name="rank" type="xsd:int" />
> </xsd:complexType>
> <xsd:element name="tranche" type="gensec:Tranche" />
>
> Thx,
>
> David
|
|
|
Re: [Teneo] Switch to DB2 and not getting identity columns [message #124985 is a reply to message #124973] |
Mon, 02 June 2008 17:27 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi David,
You should add the following annotations to the id-feature:
@Id
@GeneratedValue
(generated value has some more options, see the jpa spec for those).
What you can do is set this annotation in the EDataType and then use the EDataType for each of the
id efeatures.
gr. Martin
david wrote:
> Opps, I checked the MySQL and it did not have the auto increment set
> either. So when you replace e_id as the primary key which option is
> required to get these columns as auto increment?
>
> Thx.
>
> David
> david wrote:
>> Hi,
>>
>> I was successfully generating a schema on MySQL and getting the auto
>> increment on the id primary key column. I switched to DB2 dialect and
>> if I leave the primary key as e_id I do get IDENTITY columns but when
>> I use id in the model with the annotation I do not get them. Am I
>> missing something?
>>
>> Here are my properties
>>
>> props.setProperty(Environment.DRIVER,
>> "com.ibm.db2.jcc.DB2Driver");
>> props.setProperty(Environment.USER, "Administrator");
>> props.setProperty(Environment.PASS, "e*****");
>> props.setProperty(Environment.URL,
>> "jdbc:db2://192.168.0.3:50000/" + dbName);
>> props.setProperty(Environment.DIALECT,
>> org.hibernate.dialect.DB2Dialect.class.getName());
>> props.setProperty(PersistenceOptions.MAXIMUM_SQL_NAME_LENGTH ,
>> "30");
>>
>> props.setProperty(PersistenceOptions.ID_FEATURE_AS_PRIMARY_K EY, "true");
>> props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME ,
>> "id");
>>
>> props.setProperty(PersistenceOptions.JOIN_COLUMN_NAMING_STRA TEGY,
>> "simple");
>> props.setProperty(PersistenceOptions.ALSO_MAP_AS_CLASS, "false");
>> props.setProperty(PersistenceOptions.DEFAULT_TEMPORAL_VALUE,
>> "DATE");
>>
>> props.setProperty(PersistenceOptions.DISABLE_ECONTAINER_MAPP ING, "true");
>> props.setProperty(PersistenceOptions.ALWAYS_VERSION, "false");
>> props.setProperty(PersistenceOptions.ALWAYS_MAP_LIST_AS_BAG,
>> "true");
>> props.setProperty(PersistenceOptions.INHERITANCE_MAPPING,
>> "JOINED");
>>
>> Here is a sample of the XSD
>>
>> <xsd:complexType name="Tranche">
>> <xsd:sequence minOccurs="0" maxOccurs="1">
>> <xsd:element ref="gensec:source" />
>> </xsd:sequence>
>> <xsd:attribute name="id" type="xsd:int">
>> <xsd:annotation>
>> <xsd:appinfo source="teneo.jpa">@Id</xsd:appinfo>
>> </xsd:annotation>
>> </xsd:attribute>
>> <xsd:attribute
>> default="http://www.mddl.org/mddl/scheme/trancheIDType.xml"
>> name="scheme" use="optional" />
>> <xsd:attribute name="nameRef" type="xsd:anyURI" />
>> <xsd:attribute default="valid" name="validity"
>> type="gensec:QualityEnumeration" use="optional" />
>> <xsd:attribute name="rank" type="xsd:int" />
>> </xsd:complexType>
>> <xsd:element name="tranche" type="gensec:Tranche" />
>>
>> Thx,
>>
>> David
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
| |
Re: [Teneo] Switch to DB2 and not getting identity columns [message #619150 is a reply to message #124960] |
Mon, 02 June 2008 17:09 |
David Wynter Messages: 4624 Registered: July 2009 |
Senior Member |
|
|
Opps, I checked the MySQL and it did not have the auto increment set
either. So when you replace e_id as the primary key which option is
required to get these columns as auto increment?
Thx.
David
david wrote:
> Hi,
>
> I was successfully generating a schema on MySQL and getting the auto
> increment on the id primary key column. I switched to DB2 dialect and if
> I leave the primary key as e_id I do get IDENTITY columns but when I use
> id in the model with the annotation I do not get them. Am I missing
> something?
>
> Here are my properties
>
> props.setProperty(Environment.DRIVER, "com.ibm.db2.jcc.DB2Driver");
> props.setProperty(Environment.USER, "Administrator");
> props.setProperty(Environment.PASS, "e*****");
> props.setProperty(Environment.URL,
> "jdbc:db2://192.168.0.3:50000/" + dbName);
> props.setProperty(Environment.DIALECT,
> org.hibernate.dialect.DB2Dialect.class.getName());
> props.setProperty(PersistenceOptions.MAXIMUM_SQL_NAME_LENGTH ,
> "30");
> props.setProperty(PersistenceOptions.ID_FEATURE_AS_PRIMARY_K EY,
> "true");
> props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME ,
> "id");
>
> props.setProperty(PersistenceOptions.JOIN_COLUMN_NAMING_STRA TEGY,
> "simple");
> props.setProperty(PersistenceOptions.ALSO_MAP_AS_CLASS, "false");
> props.setProperty(PersistenceOptions.DEFAULT_TEMPORAL_VALUE,
> "DATE");
>
> props.setProperty(PersistenceOptions.DISABLE_ECONTAINER_MAPP ING, "true");
> props.setProperty(PersistenceOptions.ALWAYS_VERSION, "false");
> props.setProperty(PersistenceOptions.ALWAYS_MAP_LIST_AS_BAG,
> "true");
> props.setProperty(PersistenceOptions.INHERITANCE_MAPPING,
> "JOINED");
>
> Here is a sample of the XSD
>
> <xsd:complexType name="Tranche">
> <xsd:sequence minOccurs="0" maxOccurs="1">
> <xsd:element ref="gensec:source" />
> </xsd:sequence>
> <xsd:attribute name="id" type="xsd:int">
> <xsd:annotation>
> <xsd:appinfo source="teneo.jpa">@Id</xsd:appinfo>
> </xsd:annotation>
> </xsd:attribute>
> <xsd:attribute
> default="http://www.mddl.org/mddl/scheme/trancheIDType.xml"
> name="scheme" use="optional" />
> <xsd:attribute name="nameRef" type="xsd:anyURI" />
> <xsd:attribute default="valid" name="validity"
> type="gensec:QualityEnumeration" use="optional" />
> <xsd:attribute name="rank" type="xsd:int" />
> </xsd:complexType>
> <xsd:element name="tranche" type="gensec:Tranche" />
>
> Thx,
>
> David
|
|
|
Re: [Teneo] Switch to DB2 and not getting identity columns [message #619151 is a reply to message #124973] |
Mon, 02 June 2008 17:27 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi David,
You should add the following annotations to the id-feature:
@Id
@GeneratedValue
(generated value has some more options, see the jpa spec for those).
What you can do is set this annotation in the EDataType and then use the EDataType for each of the
id efeatures.
gr. Martin
david wrote:
> Opps, I checked the MySQL and it did not have the auto increment set
> either. So when you replace e_id as the primary key which option is
> required to get these columns as auto increment?
>
> Thx.
>
> David
> david wrote:
>> Hi,
>>
>> I was successfully generating a schema on MySQL and getting the auto
>> increment on the id primary key column. I switched to DB2 dialect and
>> if I leave the primary key as e_id I do get IDENTITY columns but when
>> I use id in the model with the annotation I do not get them. Am I
>> missing something?
>>
>> Here are my properties
>>
>> props.setProperty(Environment.DRIVER,
>> "com.ibm.db2.jcc.DB2Driver");
>> props.setProperty(Environment.USER, "Administrator");
>> props.setProperty(Environment.PASS, "e*****");
>> props.setProperty(Environment.URL,
>> "jdbc:db2://192.168.0.3:50000/" + dbName);
>> props.setProperty(Environment.DIALECT,
>> org.hibernate.dialect.DB2Dialect.class.getName());
>> props.setProperty(PersistenceOptions.MAXIMUM_SQL_NAME_LENGTH ,
>> "30");
>>
>> props.setProperty(PersistenceOptions.ID_FEATURE_AS_PRIMARY_K EY, "true");
>> props.setProperty(PersistenceOptions.DEFAULT_ID_FEATURE_NAME ,
>> "id");
>>
>> props.setProperty(PersistenceOptions.JOIN_COLUMN_NAMING_STRA TEGY,
>> "simple");
>> props.setProperty(PersistenceOptions.ALSO_MAP_AS_CLASS, "false");
>> props.setProperty(PersistenceOptions.DEFAULT_TEMPORAL_VALUE,
>> "DATE");
>>
>> props.setProperty(PersistenceOptions.DISABLE_ECONTAINER_MAPP ING, "true");
>> props.setProperty(PersistenceOptions.ALWAYS_VERSION, "false");
>> props.setProperty(PersistenceOptions.ALWAYS_MAP_LIST_AS_BAG,
>> "true");
>> props.setProperty(PersistenceOptions.INHERITANCE_MAPPING,
>> "JOINED");
>>
>> Here is a sample of the XSD
>>
>> <xsd:complexType name="Tranche">
>> <xsd:sequence minOccurs="0" maxOccurs="1">
>> <xsd:element ref="gensec:source" />
>> </xsd:sequence>
>> <xsd:attribute name="id" type="xsd:int">
>> <xsd:annotation>
>> <xsd:appinfo source="teneo.jpa">@Id</xsd:appinfo>
>> </xsd:annotation>
>> </xsd:attribute>
>> <xsd:attribute
>> default="http://www.mddl.org/mddl/scheme/trancheIDType.xml"
>> name="scheme" use="optional" />
>> <xsd:attribute name="nameRef" type="xsd:anyURI" />
>> <xsd:attribute default="valid" name="validity"
>> type="gensec:QualityEnumeration" use="optional" />
>> <xsd:attribute name="rank" type="xsd:int" />
>> </xsd:complexType>
>> <xsd:element name="tranche" type="gensec:Tranche" />
>>
>> Thx,
>>
>> David
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
| |
Goto Forum:
Current Time: Sat Apr 27 00:52:47 GMT 2024
Powered by FUDForum. Page generated in 0.03600 seconds
|