|
|
Re: [Teneo] Custom support for Hibernate/JPA annotations [message #1404985 is a reply to message #1404933] |
Wed, 06 August 2014 09:50 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hey Piotr,
On holiday, so a bit slower to respond, but this is indeed a fine/good way to do this.
gr. Martin
On 06-08-14 09:15, Piotr Ostrowski wrote:
> Ok, I solved this problem with extending TENEO:
>
>
> In app code :
>
> final HbEntityDataStore hbds = new HbEntityDataStore();
> final ExtensionManager extensionManager = hbds.getExtensionManager();
>
> extensionManager.registerExtension( ExtensionUtil.createExtension( IdMapper.class, UserIdMapper.class ) );
>
>
> Custom id mapper class:
>
> public class UserIdMapper extends IdMapper
> {
> @Override
> public void processEmbeddedId( PAnnotatedEReference aReference )
> {
> super.processEmbeddedId( aReference );
> Element eReferenceElement = getHbmContext().getCurrent();
> addSequeceForCompositeId( eReferenceElement );
> }
> private void addSequeceForCompositeId( Element eReferenceElement )
> {
> Element compositeIdElement = eReferenceElement.element( "composite-id" );
> if( compositeIdElement != null )
> {
> Element generatorElement = DocumentHelper.createElement( "generator" );
> generatorElement.addAttribute( "class", UserIdGenerator.class.getName() );
> compositeIdElement.add( generatorElement );
> }
> }
> }
--
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
|
|
|
Powered by
FUDForum. Page generated in 0.03945 seconds