Re: "failed to provide new primary keys for entity"
Re: "failed to provide new primary keys for entity"
- Subject: Re: "failed to provide new primary keys for entity"
- From: Johnny Miller <email@hidden>
- Date: Tue, 23 Feb 2010 21:22:29 -1000
On Feb 23, 2010, at 8:32 PM, Chuck Hill wrote:
>
> On Feb 23, 2010, at 9:05 PM, Johnny Miller wrote:
>
>>
>> On Feb 23, 2010, at 5:47 PM, Chuck Hill wrote:
>>
>>>
>>> On Feb 23, 2010, at 7:38 PM, Johnny Miller wrote:
>>>
>>>> Hi Kieran,
>>>>
>>>> Yeah, I haven't changed anything except to add an attribute to the intermediary table and I also exposed the two to-one relationships in the intermediary table as class properties.
>>>
>>> Are the attributes these based on still not exposed (they should not be exposed)?
>>
>> A < - >> AB << - > B
>>
>> I exposed ab.a and ab.b. The rest of the relationships are the way the wizard created it.
>
> Not relationships. Attributes. Are the FK attributes exposed?
>
No, they are not. They are set as primary keys and they are set as to be used for locking.
>
>
>>
>>>
>>> Have you changed the data types of the keys?
>>
>> No.
>>
>>> Check the two objects with relationships INTO this join EO. Are the relationships still set to Propogate Primary Key?
>>
>> Yes.
>>
>>> Check editingContext().insertedObjects() to ensure that you are not getting TWO of these objects created.
>>>
>>
>> Just one object gets created. It says the pk is null?
>>
>> thanks,
>>
>> johnny
>>
>>
>>
>>>
>>> Chuck
>>>
>>>
>>>>
>>>> I just deleted everything and recreated it again and I'm still getting the same error.
>>>>
>>>> I don't see any SQL getting logged that indicates it's trying to insert a row. It seems to be erring out before it tries to write to the database.
>>>>
>>>> Thanks for helping,
>>>>
>>>> Johnny
>>>>
>>>>
>>>>
>>>> On Feb 23, 2010, at 5:05 PM, Kieran Kelleher wrote:
>>>>
>>>>>
>>>>> On Feb 23, 2010, at 3:55 PM, Johnny Miller wrote:
>>>>>
>>>>>> Actually, there is no "primary" key. There are just the two "multi-occurence" keys for the two foreign keys that are propagated by the relationships.
>>>>>
>>>>> Is the join table setup **exactly** the same as if you let Entity Modeler create it automatically for you via the relationship wizard? If it was, the join would be created automatically.
>>>>>
>>>>>
>>>>>>
>>>>>> I thought that was OK because that's the default when you create a multi-to-multi join. And I do the exact same thing in another model, which is the really perplexing part.
>>>>>>
>>>>>> Do you think just creating a primary key in the database that is auto incremented by MySQL would solve it?
>>>>>
>>>>> IMHO, Bad idea ..... probably will not work ....... one reason is EOF has no clue what PK was assigned by MySQL automatically in an autoincrement field...... probably more reasons too. If that worked, then why would we even need EO PK TABLE. EOF assigned PKs _before_ inserting a record in the database. MYSQL autoincrement assignment happens _after_ the query is received to insert a record in a table.
>>>>>
>>>>>
>>>>>>
>>>>>> Thanks Don.
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Feb 23, 2010, at 10:49 AM, Don Lindsay wrote:
>>>>>>
>>>>>>> This sounds like you have a compound primary key? A primary key with more than one field or that your primary key is not something that WebObjects can generate (string, etc).
>>>>>>>
>>>>>>> The easiest way to use web objects is to create a primary key that is a number and use it. Not use other fields in the table, just create a number field that is the primary key this will save you lots of hair pulling.
>>>>>>>
>>>>>>> Don
>>>>>>> On Feb 23, 2010, at 3:00 PM, Johnny Miller wrote:
>>>>>>>
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> I have a many to many join with flattened relationships that I created using the new relationship wizard in Entity Modeler.
>>>>>>>>
>>>>>>>> I then added a class property to the intermediary table and changed the class name from EOGeneric record to an appropriate one for the entity and package. Basically I need to know the "order" of the objects in the table so I ascribed a position value.
>>>>>>>>
>>>>>>>> After I create the object and attempt to save it I'm getting the error "failed to provide new primary keys for entity". I've checked the database and the table exists, the foreign keys are created and I've actually compared it to another table/model where I've done exactly the same thing without an issue.
>>>>>>>>
>>>>>>>>
>>>>>>>> I'm using ...
>>>>>>>> WO 5.4.3
>>>>>>>> Recent version of Wonder
>>>>>>>> MySQL 5.1.37, using the MySQL plugin supplied by someone on the list .
>>>>>>>> OS X 10.6
>>>>>>>>
>>>>>>>> stack trace:
>>>>>>>>
>>>>>>>> IllegalStateException: Adaptor com.webobjects.jdbcadaptor.JDBCAdaptor@779a639b failed to provide new primary keys for entity 'MAP_Gallery_Image'
>>>>>>>> at com.webobjects.eoaccess.EODatabaseContext.prepareForSaveWithCoordinator(EODatabaseContext.java:5713)
>>>>>>>> at com.webobjects.eocontrol.EOObjectStoreCoordinator.saveChangesInEditingContext(EOObjectStoreCoordinator.java:370)
>>>>>>>> at com.webobjects.eocontrol.EOEditingContext.saveChanges(EOEditingContext.java:3192)
>>>>>>>> at er.extensions.eof.ERXEC._saveChanges(ERXEC.java:981)
>>>>>>>> at er.extensions.eof.ERXEC.saveChanges(ERXEC.java:903)
>>>>>>>> at com.kahalawai.components.pages.media.SetGalleryImagesPage.saveChanges(SetGalleryImagesPage.java:63)
>>>>>>>> ... skipped 68 stack elements
>>>>>>>>
>>>>>>>> I don't see an insert SQL command in the SQL log.
>>>>>>>>
>>>>>>>>
>>>>>>>> Johnny Miller
>>>>>>>> Kahalawai Media Corp
>>>>>>>> http://www.kahalawai.com
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> Do not post admin requests to the list. They will be ignored.
>>>>>>>> Webobjects-dev mailing list (email@hidden)
>>>>>>>> Help/Unsubscribe/Update your Subscription:
>>>>>>>>
>>>>>>>> This email sent to email@hidden
>>>>>>>
>>>>>>
>>>>>> Johnny Miller
>>>>>> Kahalawai Media Corp
>>>>>> http://www.kahalawai.com
>>>>>>
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> Do not post admin requests to the list. They will be ignored.
>>>>>> Webobjects-dev mailing list (email@hidden)
>>>>>> Help/Unsubscribe/Update your Subscription:
>>>>>>
>>>>>> This email sent to email@hidden
>>>>>
>>>>
>>>> Johnny Miller
>>>> Kahalawai Media Corp
>>>> http://www.kahalawai.com
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> Do not post admin requests to the list. They will be ignored.
>>>> Webobjects-dev mailing list (email@hidden)
>>>> Help/Unsubscribe/Update your Subscription:
>>>>
>>>> This email sent to email@hidden
>>>
>>> --
>>> Chuck Hill Senior Consultant / VP Development
>>>
>>> Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
>>> http://www.global-village.net/products/practical_webobjects
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>
>> Johnny Miller
>> Kahalawai Media Corp
>> http://www.kahalawai.com
>>
>>
>>
>
> --
> Chuck Hill Senior Consultant / VP Development
>
> Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
> http://www.global-village.net/products/practical_webobjects
>
>
>
>
>
>
>
Johnny Miller
Kahalawai Media Corp
http://www.kahalawai.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden