Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [Teneo] idBag ID generator(configurable ID generator for idBag)
[Teneo] idBag ID generator [message #1063911] Sat, 15 June 2013 05:31 Go to next message
R Deepak is currently offline R DeepakFriend
Messages: 20
Registered: July 2011
Junior Member
Can the ID generator for idBag be made configurable?

I am using Teneo 1.2.0.v201202122052.

I want to change the ID generator for idBag to sequence. If I run 2 JVMs, and they write to the same collection in parallel, we get a unique constraint violation exception.

I looked at AbstractAssociationMapper in method

	protected Element addCollectionElement


The generator is hard coded to increment.

if (idBag != null) {
			final String generator = (idBag.getGenerator() == null ? "increment"
					: idBag.getGenerator());
			final String type = (idBag.getType() == null ? "long" : idBag
					.getType());
			// if (false && idBag.getTable() != null) {
			// collectionElement.addAttribute("table", idBag.getTable());
			// }
			final Element collectionIdElement = collectionElement
					.addElement("collection-id");
			collectionIdElement.addAttribute("column",
					hbmContext.getIdbagIDColumnName());
			collectionIdElement.addAttribute("type", type);

			collectionIdElement.addElement("generator").addAttribute("class",
					generator);
		}
Re: [Teneo] idBag ID generator [message #1063929 is a reply to message #1063911] Sun, 16 June 2013 06:52 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5340
Registered: July 2009
Senior Member
Hi R Deepak,
Afaik the Idbag annotation has a generator attribute which can be use to set the generator, have you tried that?

gr. Martin

On 06/15/2013 07:31 AM, R Deepak wrote:
> Can the ID generator for idBag be made configurable?
>
> I am using Teneo 1.2.0.v201202122052.
> I want to change the ID generator for idBag to sequence. If I run 2 JVMs, and they write to the same collection in
> parallel, we get a unique constraint violation exception.
>
> I looked at AbstractAssociationMapper in method
>
> protected Element addCollectionElement
>
>
> The generator is hard coded to increment.
>
>
> if (idBag != null) {
> final String generator = (idBag.getGenerator() == null ? "increment"
> : idBag.getGenerator());
> final String type = (idBag.getType() == null ? "long" : idBag
> .getType());
> // if (false && idBag.getTable() != null) {
> // collectionElement.addAttribute("table", idBag.getTable());
> // }
> final Element collectionIdElement = collectionElement
> .addElement("collection-id");
> collectionIdElement.addAttribute("column",
> hbmContext.getIdbagIDColumnName());
> collectionIdElement.addAttribute("type", type);
>
> collectionIdElement.addElement("generator").addAttribute("class",
> generator);
> }
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [Teneo] idBag ID generator [message #1064172 is a reply to message #1063929] Tue, 18 June 2013 05:18 Go to previous messageGo to next message
R Deepak is currently offline R DeepakFriend
Messages: 20
Registered: July 2011
Junior Member
Hi Martin

Martin Taal wrote on Sun, 16 June 2013 02:52
Hi R Deepak,
Afaik the Idbag annotation has a generator attribute which can be use to set the generator, have you tried that?


The model I am using is too big and complex. So, I have not tuned individual collections. May not be a viable option for me..

I have used the global option

teneo.mapping.map_all_lists_as_idbag

Will it work if I modify AbstractAssociationMapper and change increment to sequence?

Thanks
Deepak
Re: [Teneo] idBag ID generator [message #1064247 is a reply to message #1064172] Tue, 18 June 2013 11:57 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5340
Registered: July 2009
Senior Member
Hi Deepak,
You can not override the abstract class but you can override one of its subclasses and override specific methods. Check
out the source code. Then you can tell Teneo to use your class with this mechanism:
http://wiki.eclipse.org/Teneo/Hibernate/Extensions

gr. Martin

On 06/18/2013 07:18 AM, R Deepak wrote:
> Hi Martin
>
> Martin Taal wrote on Sun, 16 June 2013 02:52
>> Hi R Deepak,
>> Afaik the Idbag annotation has a generator attribute which can be use to set the generator, have you tried that?
>
>
> The model I am using is too big and complex. So, I have not tuned individual collections. May not be a viable option for
> me..
>
> I have used the global option
> teneo.mapping.map_all_lists_as_idbag
>
> Will it work if I modify AbstractAssociationMapper and change increment to sequence?
>
> Thanks
> Deepak


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [Teneo] idBag ID generator [message #1064249 is a reply to message #1064247] Tue, 18 June 2013 12:06 Go to previous messageGo to next message
R Deepak is currently offline R DeepakFriend
Messages: 20
Registered: July 2011
Junior Member
Martin Taal wrote on Tue, 18 June 2013 07:57
Hi Deepak,
You can not override the abstract class but you can override one of its subclasses and override specific methods. Check
out the source code. Then you can tell Teneo to use your class with this mechanism:
http://wiki.eclipse.org/Teneo/Hibernate/Extensions


The subclasses calling the method "addCollectionElement" include:

ManyAttributeMapper
ManyExternalReferenceMapper
ManyToManyMapper
OneToManyMapper
TypedEReferenceMapper

Should I override all these and replace it using extensionManager.registerExtension()?
Re: [Teneo] idBag ID generator [message #1064275 is a reply to message #1064249] Tue, 18 June 2013 14:15 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5340
Registered: July 2009
Senior Member
Hi Deepak,
Probably only the ManyToMany and OneToMany as only these one use the idbag.

gr. Martin

On 06/18/2013 02:06 PM, R Deepak wrote:
> Martin Taal wrote on Tue, 18 June 2013 07:57
>> Hi Deepak,
>> You can not override the abstract class but you can override one of its subclasses and override specific methods.
>> Check out the source code. Then you can tell Teneo to use your class with this mechanism:
>> http://wiki.eclipse.org/Teneo/Hibernate/Extensions
>
>
> The subclasses calling the method "addCollectionElement" include:
>
> ManyAttributeMapper
> ManyExternalReferenceMapper
> ManyToManyMapper
> OneToManyMapper
> TypedEReferenceMapper
>
> Should I override all these and replace it using extensionManager.registerExtension()?
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [Teneo] idBag ID generator [message #1064384 is a reply to message #1064275] Wed, 19 June 2013 04:41 Go to previous message
R Deepak is currently offline R DeepakFriend
Messages: 20
Registered: July 2011
Junior Member
It works..

Thanks Martin.
Previous Topic:JSON Resources from EMF ?
Next Topic:[EMF/GMF] - Performance issue on load and save model.
Goto Forum:
  


Current Time: Mon Dec 22 10:52:15 GMT 2014

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

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