You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by "nico (JIRA)" <ji...@apache.org> on 2011/06/01 16:54:47 UTC

[jira] [Issue Comment Edited] (CAY-1576) PK Generation with "meaningful PK"

    [ https://issues.apache.org/jira/browse/CAY-1576?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13042209#comment-13042209 ] 

nico edited comment on CAY-1576 at 6/1/11 2:53 PM:
---------------------------------------------------

I found something.
I think it can be done with 
DataContext context = DataContext.createDataContext();
((PostgresAdapter)context.getParentDataDomain().getNode("someNodeYouCreatedWithModeler").getAdapter()).setSupportsGeneratedKeys(true);

because it is not supported by default.
But I think it would be nice, if I can configure it in Cayenne Modeler.

      was (Author: hype11):
    I found something.
I think it can be done with 
DataContext context = DataContext.createDataContext();
((PostgresAdapter)context.getParentDataDomain().getNode("PostgreNode").getAdapter()).setSupportsGeneratedKeys(true);

because it is not supported by default.
But I think it would be nice, if I can configure it in Cayenne Modeler.
  
> PK Generation with "meaningful PK"
> ----------------------------------
>
>                 Key: CAY-1576
>                 URL: https://issues.apache.org/jira/browse/CAY-1576
>             Project: Cayenne
>          Issue Type: Question
>          Components: Database integration
>    Affects Versions: 3.1M1
>         Environment: Win7 with PostgreSQL 9
>            Reporter: nico
>              Labels: features
>
> I have a question about the primary generation.
> I generate all classes with the Cayenne Modeler from the database with "meaningful PK" option, because I need the getId()-method from the entity, which gives me the Pk from the database.
> I set the Pk Generation Stategy to Database-Generated in all DbEntities, because I don't wan't to set the Pk by myself or by Cayenne, but by database.
> Now I have the situation that Cayenne fetch the first PK from DB by calling the sequence in Db, then Cayenne increment the ID 20 times (on 20 inserts) and send the IDs (PKs) to database, then cayenne call another time the sequence for next Pk id and so on.
> But I don't want that cayenne send any generated PK Id to database and only let the database generate the Ids. I think this is a result of the "meaningful PK" setting.
> Is there any solution to get the database PK Id from a Object Entity (at best with getId()-method) without a database call and let the database generate the primary keys?
> I hope this is understandable.
> thanks in advance

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira