Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » ArrayOutOfBoundsException: -14
ArrayOutOfBoundsException: -14 [message #1012325] Thu, 21 February 2013 10:57 Go to next message
Ludwig Moser is currently offline Ludwig MoserFriend
Messages: 476
Registered: July 2009
Senior Member
i've got an EClass with an EReference

in my database layer (hibernate) i extend the default EMF Class and add a function to map (my old database) to the EMF construct (old db has only one field, whereat the new db will have a list)

 /**
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 * 
 * @generated NOT
 */
public Contact get__hbm__attendant() {
	if (getMoreContacts().size() > 0) {
		return getMoreContacts().get(0);
	}
	return null;
}


/**
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 * 
 * @generated NOT
 */
public void set__hbm__attendant(Contact newContact) {
	Contact oldContact = get__hbm__attendant();
		if (newContact != null && !getMoreContacts().contains(newContact)) {
		try {
			getMoreContacts().add(newContact);
		} catch (Exception e) {
			System.err.println("the exception will be here");
			e.printStackTrace();
		}
	}
		if (eNotificationRequired())
		eNotify(new ENotificationImpl(this, Notification.SET,
				FrameworkPackage.EXCURSION__MORE_CONTACTS, ldContact,
				newContact));
}

this code looks correct to me, can you point me to my mistake? as the following exception gets raised:
java.lang.ArrayIndexOutOfBoundsException: -14
	at org.eclipse.emf.ecore.impl.BasicEObjectImpl$EPropertiesHolderBaseImpl.dynamicGet(BasicEObjectImpl.java:159
)
	at org.eclipse.emf.ecore.impl.EStructuralFeatureImpl$InternalSettingDelegateMany.dynamicInverseRemove(EStruct
uralFeatureImpl.java:1775)
	at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eDynamicInverseRemove(BasicEObjectImpl.java:1468)
	at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eInverseRemove(BasicEObjectImpl.java:1457)
	at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eInverseRemove(BasicEObjectImpl.java:1447)
	at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eBasicRemoveFromContainer(BasicEObjectImpl.java:1396)
	at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eInverseAdd(BasicEObjectImpl.java:1421)
	at org.eclipse.emf.ecore.util.EcoreEList.inverseAdd(EcoreEList.java:292)
	at org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUnique(NotifyingListImpl.java:318)
	at org.eclipse.emf.common.util.AbstractEList.add(AbstractEList.java:307)
	at framework.persistence.mssql.impl.MSSQLExcursionImpl.set__hbm__attendant(MSSQLExcursionImpl.java:61)
	at framework.persistence.mssql.impl.MSSQLExcursionImpl$$BulkBeanByCGLIB$$dd08f4c6.setPropertyValues(<gener
ated>)
	at org.hibernate.tuple.PojoEntityTuplizer.setPropertyValuesWithOptimizer(PojoEntityTuplizer.java:212)
	at org.hibernate.tuple.PojoEntityTuplizer.setPropertyValues(PojoEntityTuplizer.java:185)
	at org.hibernate.persister.entity.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:3232
)
	at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:129)
	at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:842)
	at org.hibernate.loader.Loader.doQuery(Loader.java:717)
	at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
	at org.hibernate.loader.Loader.doList(Loader.java:2145)
	at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
	at org.hibernate.loader.Loader.list(Loader.java:2024)
	at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:94)
	at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1533)
	at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
	at tests.test_real_classes.find(test_real_classes.java:139)
	at tests.test_real_classes.test_excursion(test_real_classes.java:81)
	at tests.test_real_classes.main(test_real_classes.java:67)
Re: ArrayOutOfBoundsException: -14 [message #1012334 is a reply to message #1012325] Thu, 21 February 2013 11:18 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33107
Registered: July 2009
Senior Member
Ludwig,

Comments below.

On 21/02/2013 11:57 AM, Ludwig Moser wrote:
> i've got an EClass with an EReference
>
> in my database layer (hibernate) i extend the default EMF Class and
> add a function to map (my old database) to the EMF construct (old db
> has only one field, whereat the new db will have a list)
>
>
> /**
> * <!-- begin-user-doc --> <!-- end-user-doc -->
> * * @generated NOT
> */
> public Contact get__hbm__attendant() {
> if (getMoreContacts().size() > 0) {
> return getMoreContacts().get(0);
> }
> return null;
> }
>
>
> /**
> * <!-- begin-user-doc --> <!-- end-user-doc -->
> * * @generated NOT
> */
> public void set__hbm__attendant(Contact newContact) {
> Contact oldContact = get__hbm__attendant();
> if (newContact != null &&
> !getMoreContacts().contains(newContact)) {
> try {
> getMoreContacts().add(newContact);
> } catch (Exception e) {
> System.err.println("the exception will be here");
> e.printStackTrace();
> }
> }
> if (eNotificationRequired())
> eNotify(new ENotificationImpl(this, Notification.SET,
> FrameworkPackage.EXCURSION__MORE_CONTACTS, ldContact,
> newContact));
> }
> this code looks correct to me, can you point me to my mistake?
Have you changed the model and regenerated it?
> as the following exception gets raised:
> java.lang.ArrayIndexOutOfBoundsException: -14
> at
> org.eclipse.emf.ecore.impl.BasicEObjectImpl$EPropertiesHolderBaseImpl.dynamicGet(BasicEObjectImpl.java:159
> )
> at
> org.eclipse.emf.ecore.impl.EStructuralFeatureImpl$InternalSettingDelegateMany.dynamicInverseRemove(EStruct
> uralFeatureImpl.java:1775)
> at
> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eDynamicInverseRemove(BasicEObjectImpl.java:1468)
> at
> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eInverseRemove(BasicEObjectImpl.java:1457)
> at
> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eInverseRemove(BasicEObjectImpl.java:1447)
> at
> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eBasicRemoveFromContainer(BasicEObjectImpl.java:1396)
Is newContract.eContainer() non null? It looks like it's needed to
remove it from its current container and that this is going astray.
> at
> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eInverseAdd(BasicEObjectImpl.java:1421)
>
> at
> org.eclipse.emf.ecore.util.EcoreEList.inverseAdd(EcoreEList.java:292)
> at
> org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUnique(NotifyingListImpl.java:318)
> at
> org.eclipse.emf.common.util.AbstractEList.add(AbstractEList.java:307)
> at
> framework.persistence.mssql.impl.MSSQLExcursionImpl.set__hbm__attendant(MSSQLExcursionImpl.java:61)
> at
> framework.persistence.mssql.impl.MSSQLExcursionImpl$$BulkBeanByCGLIB$$dd08f4c6.setPropertyValues(<gener
> ated>)
> at
> org.hibernate.tuple.PojoEntityTuplizer.setPropertyValuesWithOptimizer(PojoEntityTuplizer.java:212)
> at
> org.hibernate.tuple.PojoEntityTuplizer.setPropertyValues(PojoEntityTuplizer.java:185)
> at
> org.hibernate.persister.entity.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:3232
> )
> at
> org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:129)
> at
> org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:842)
> at org.hibernate.loader.Loader.doQuery(Loader.java:717)
> at
> org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
> at org.hibernate.loader.Loader.doList(Loader.java:2145)
> at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
> at org.hibernate.loader.Loader.list(Loader.java:2024)
> at
> org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:94)
> at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1533)
> at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
> at tests.test_real_classes.find(test_real_classes.java:139)
> at tests.test_real_classes.test_excursion(test_real_classes.java:81)
> at tests.test_real_classes.main(test_real_classes.java:67)
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: ArrayOutOfBoundsException: -14 [message #1012751 is a reply to message #1012334] Fri, 22 February 2013 07:21 Go to previous messageGo to next message
Ludwig Moser is currently offline Ludwig MoserFriend
Messages: 476
Registered: July 2009
Senior Member
>Have you changed the model and regenerated it?
yes i edited and regenerated everything to be sure everything is fine.

>Is newContract.eContainer() non null? It looks like it's needed to
>remove it from its current container and that this is going astray.
removing it from its current container? do you mean a containment? so an contact can only be on one excursion?
i did not specify this. a contact can be standalone or attached to whatever.

the eContainer is sometimes null sometimes not.
if its eContainer is null, all is fine.
if its eContainer is not null the exception raises

the eReference has properties:
changeable: true
container: false;
containment: false
derived: false
ordered: true
resolveProxies: true;
transient: false;
unique: true;
unsettable:false;
volatile: false
bounds 0..*


NOTE: i got an EClass interface MoreContactsBean, which includes the eReference 0..* moreContacts:Contact;
and i defined an EClass Excursion, which got MoreContactsBean as supertype
this should be fine, right? (does not create statics, so every excursion instance has its own ereference to contacts - they do not share one.)
Re: ArrayOutOfBoundsException: -14 [message #1012814 is a reply to message #1012751] Fri, 22 February 2013 09:09 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33107
Registered: July 2009
Senior Member
Ludwig,

Comments below.

On 22/02/2013 8:21 AM, Ludwig Moser wrote:
>> Have you changed the model and regenerated it?
> yes i edited and regenerated everything to be sure everything is fine.
>
>> Is newContract.eContainer() non null? It looks like it's needed to
>> remove it from its current container and that this is going astray.
> removing it from its current container? do you mean a containment? so
> an contact can only be on one excursion?
Yes any given object can only be a member of at most one containment
reference.
> i did not specify this. a contact can be standalone or attached to
> whatever.
When I see
org.eclipse.emf.ecore.impl.BasicEObjectImpl.eBasicRemoveFromContainer(BasicEObjectImpl.java:1396) on
the stack, I'm quite sure you're dealing with a containment reference.
>
> the eContainer is sometimes null sometimes not.
> if its eContainer is null, all is fine.
> if its eContainer is not null the exception raises
Yes it's clear there's an attempt to remove the object from its current
container.
>
> the eReference has properties:
> changeable: true
> container: false;
> containment: false
> derived: false
> ordered: true
> resolveProxies: true;
> transient: false;
> unique: true;
> unsettable:false;
> volatile: false
> bounds 0..*
The feature of the list involved is certainly behaving like it's one for
a containment reference.
>
> NOTE: i got an EClass interface MoreContactsBean, which includes the
> eReference 0..* moreContacts:Contact;
> and i defined an EClass Excursion, which got MoreContactsBean as
> supertype
> this should be fine, right?
Yes.
> (does not create statics, so every excursion instance has its own
> ereference to contacts - they do not share one.)
I'm not sure I follow. I can only emphasize that what you're showing in
the stack looks like an EObjectContainmentEList is involved.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: ArrayOutOfBoundsException: -14 [message #1012825 is a reply to message #1012814] Fri, 22 February 2013 09:42 Go to previous messageGo to next message
Ludwig Moser is currently offline Ludwig MoserFriend
Messages: 476
Registered: July 2009
Senior Member
okay, to be sure i now looked at the ecore in text mode and searched for containment="true"
this is not set on anything regarding Excursion or Contact.

i remember that i got containments in the beginning. probably this is still left somewhere in the generated files??
(i did not delete my src files (i just hit "generate model code" in the genmodel) as i have quite some generated NOT code in there...
Re: ArrayOutOfBoundsException: -14 [message #1012828 is a reply to message #1012825] Fri, 22 February 2013 09:46 Go to previous messageGo to next message
Ludwig Moser is currently offline Ludwig MoserFriend
Messages: 476
Registered: July 2009
Senior Member
EDIT: looked through the Excursion code, and noticed that getMoreContacts is set to generated NOT (with an EObjectContainmentEList) - which is incorrect

i guess this will fix my problem.

thanks for you rapid help, ed!
your help is solid as a rock ;D
Re: ArrayOutOfBoundsException: -14 [message #1012831 is a reply to message #1012828] Fri, 22 February 2013 09:51 Go to previous messageGo to next message
Ludwig Moser is currently offline Ludwig MoserFriend
Messages: 476
Registered: July 2009
Senior Member
note: even when i regenerate the src its generating a EObjectContainmentEList instead of EObjectResolvingEList
Re: ArrayOutOfBoundsException: -14 [message #1012835 is a reply to message #1012831] Fri, 22 February 2013 09:57 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33107
Registered: July 2009
Senior Member
I'm sure if it's generating that, your model it instructing it to do that.

On 22/02/2013 10:51 AM, Ludwig Moser wrote:
> note: even when i regenerate the src its generating a
> EObjectContainmentEList instead of EObjectResolvingEList


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:[CDO] setting signal Timeout causes timeout exception.
Next Topic:[CDO/Teneo] How to create HibernateStore programatically? / org.hibernate.MappingException: Could no
Goto Forum:
  


Current Time: Tue Mar 19 09:34:54 GMT 2024

Powered by FUDForum. Page generated in 0.02509 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top