cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Felipe Martín Santos <gadita...@gmail.com>
Subject Insert Meaningful Primary Key
Date Tue, 11 Sep 2012 11:22:41 GMT
hello, I'm using cayenne 3.0.2. In most of tables I use a Custom Sequence
to generate the Primary Keys, but in some tables I use Meaningful Primary
Key and here's the problem

In my java code I use generic DataObjects
DataContext context = DataContext.createDataContext();
DataMap orMapping =
context.getEntityResolver().getDataMap("ExampleDomainMap");

When I try to insert a new Object, I've problems with the database:

*DataObject city = context.createAndRegisterNewObject("City");
city.writeProperty("cdCity", new Integer("11"));
city.writeProperty("dsCity", "Cadiz");*

* context.commitChanges();*

cdCity is the PK, here the db and object entity definition:

<db-entity name="CITY" >
        <db-attribute name="CD_CITY" type="NUMERIC" isPrimaryKey="true"
isMandatory="true" length="2"/>
        <db-attribute name="DS_CITY" type="VARCHAR" isMandatory="true"
length="50"/>
 </db-entity>

<obj-entity name="Provincia"
className="es.juntadeandalucia.agapa.sigpac.pojo.Provincia"
dbEntityName="SIGPACP_PROVINCIAS">
        <obj-attribute name="cdCity" type="java.lang.Integer"
db-attribute-path="CD_CITY"/>
        <obj-attribute name="dsCity" type="java.lang.String"
db-attribute-path="DS_CITY"/>
   </obj-entity>

I've the next error:

*Exception in thread "main" org.apache.cayenne.CayenneRuntimeException:
[v.3.0RC2 Feb 03 2010 13:38:54] Commit Exception
    at
org.apache.cayenne.access.DataContext.flushToParent(DataContext.java:1134)
    at
org.apache.cayenne.access.DataContext.commitChanges(DataContext.java:1045)
    at CayenneMain.workWithGenericObjects(CayenneMain.java:138)
    at CayenneMain.main(CayenneMain.java:49)
Caused by: java.sql.SQLException: Tipo de columna no válido: 2147483647*


I've tried with differents options:

*city.writeProperty("cdCity", new Integer("11"));
city.writeProperty("cdCity", 11) *and other types of Java Numbers.... But* *I
get always the same error.


Can somebody help me please?

Is recommended using Meaningful Primary Key?


Thanks!!


*
*

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message