cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scott Anderson" <sander...@airvana.com>
Subject RE: Specifying PK when creating a new object in DB generated PK mode
Date Tue, 06 May 2008 14:33:20 GMT
Works great; thanks Andrus.

-----Original Message-----
From: Andrus Adamchik [mailto:andrus@objectstyle.org] 
Sent: Tuesday, May 06, 2008 4:30 AM
To: user@cayenne.apache.org
Subject: Re: Specifying PK when creating a new object in DB generated PK
mode

How about using a brute force approach. You have a DataMap that  
contains DbEntities with "Database Generated" PK. Fine... but for  
import purposes you need to suppress this behavior, so do something  
like that on startup:

DataDomain domain = Configuration.getSharedConfiguration().getDomain();
for(DbEntity e : domain.getEntityResolver().getDbEntities()) {
    for(DbAttribute a : e.getPrimaryKeys()) {
       a.setGenerated(false);
    }
}


Andrus

Mime
View raw message