cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aristedes Maniatis <>
Subject Re: Insert Meaningful Primary Key
Date Tue, 11 Sep 2012 12:09:24 GMT
On 11/09/12 9:22pm, Felipe Martín Santos wrote:

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

You are better just writing:

city = context.newObject(City.class);

>          <db-attribute name="CD_CITY" type="NUMERIC" isPrimaryKey="true"
> isMandatory="true" length="2"/>

Length 2?

> Is recommended using Meaningful Primary Key?

It is almost never a good idea to use a meaningful primary key. Other than when you need to
refactor an existing badly written database and you are stuck with it, I can think of no valid
reason to do so. Just let Cayenne handle it for you.


Aristedes Maniatis
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A

View raw message