Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [EMF + Teneo + EAV]: How to customize table names used in EAV schema?
[EMF + Teneo + EAV]: How to customize table names used in EAV schema? [message #516696] Wed, 24 February 2010 20:05 Go to next message
tr  is currently offline tr Friend
Messages: 5
Registered: November 2009
Junior Member
Hi,

Our project is using Teneo EAV schema. Now everytime a new HbSessionDatastore gets created, I need to append different appendixes to the table names used in eav schema. E.g.

For HbSessionDataStore1, I want "eaveobject" table to be named as "eaveobject_store1". And for HbSessionDataStore2, I want "eaveobject" table to be named as "eaveobject_store2".

Is there any easy way to achieve this? I tried to (1) extending Hibernate DefaultNamingStrategy (2) extending Teneo's SQLNameStrategy extensionpoint. But these two seems to have no effect on table names used in EAV schema.

Another way I can use is to modify eav schema's eav.hbm.xml, and for each new HbSessionDatastore, use PersistenceOptions.EAV_MAPPING_FILE option to point to the newly updated mapping xml. But is there any easier way that I missed here?

Thanks in advance!

Re: [EMF + Teneo + EAV]: How to customize table names used in EAV schema? [message #516857 is a reply to message #516696] Thu, 25 February 2010 06:46 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi tr,
Hmm, within Teneo there is currently no other way than overriding the hbm file used here. But maybe Hibernate offers
some configuration options:

You could try to use the hibernate catalog/schema properties. With these you can define prefixes which are prepended to
table names by hibernate.

Another way (although seems more hackish) is to use an interceptor, see here for an example:
http://java.dzone.com/articles/hibernate-dynamic-table-routi n
Note that when using an interceptor that you have to extend the EMFInterceptor class (provided by Teneo) and declare
that class using the Teneo extension mechanism:
http://wiki.eclipse.org/Teneo/Hibernate/Extensions

Let me know if one of the above strategies helps.

gr. Martin

tr wrote:
> Hi,
> Our project is using Teneo EAV schema. Now everytime a new
> HbSessionDatastore gets created, I need to append different appendixes
> to the table names used in eav schema. E.g.
> For HbSessionDataStore1, I want "eaveobject" table to be named as
> "eaveobject_store1". And for HbSessionDataStore2, I want "eaveobject"
> table to be named as "eaveobject_store2".
>
> Is there any easy way to achieve this? I tried to (1) extending
> Hibernate DefaultNamingStrategy (2) extending Teneo's SQLNameStrategy
> extensionpoint. But these two seems to have no effect on table names
> used in EAV schema.
> Another way I can use is to modify eav schema's eav.hbm.xml, and for
> each new HbSessionDatastore, use PersistenceOptions.EAV_MAPPING_FILE
> option to point to the newly updated mapping xml. But is there any
> easier way that I missed here?
> Thanks in advance!
>
>


--

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@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [EMF + Teneo + EAV]: How to customize table names used in EAV schema? [message #516915 is a reply to message #516857] Thu, 25 February 2010 14:14 Go to previous messageGo to next message
tr  is currently offline tr Friend
Messages: 5
Registered: November 2009
Junior Member
Dear Martin,

The first approach will point to different schemas, e.g. if I set 'schema="ppp"'. It will point me to "ppp.eaveobject" instead of "ppp_eaveobject" table. This approach works for Oracle. But for SQLServer we like everything to be under "dbo". And MySQL doesn't even have real schema support.

The second approach is actually a little hacky... If we want to go that way, I might just override your PersistenceFileProvider extension point, in its getFileContent() function, do something like:
if it's "eav.hbm.xml", then modify the table attribute and append some content.

Also there is a third cleaner approach. Is it possible/difficult to allow PersistenceOptions.SQL_TABLE_NAME_PREFIX to take effect for EAV schema? Right now it doesn't affect EAV table names. But one reason I could think of, is that some companies have strict policies on what should be their database table's prefix. Now they would want their table names to be prefixed, no matter traditional schema or EAV schema.

Thanks

Tiger
Re: [EMF + Teneo + EAV]: How to customize table names used in EAV schema? [message #516953 is a reply to message #516915] Thu, 25 February 2010 15:05 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Tiger,
Yes having the option seems to be the cleanest approach from a usability point of view. I hope to find an implementation
of this option also which is as clean. Can you enter a bugzilla for this then we can discuss it further there?

gr. Martin

tr wrote:
> Dear Martin,
> The first approach will point to different schemas, e.g. if I set
> 'schema="ppp"'. It will point me to "ppp.eaveobject" instead of
> "ppp_eaveobject" table. This approach works for Oracle. But for
> SQLServer we like everything to be under "dbo". And MySQL doesn't even
> have real schema support.
> The second approach is actually a little hacky... If we want to go that
> way, I might just override your PersistenceFileProvider extension point,
> in its getFileContent() function, do something like: if it's
> "eav.hbm.xml", then modify the table attribute and append some content.
> Also there is a third cleaner approach. Is it possible/difficult to
> allow PersistenceOptions.SQL_TABLE_NAME_PREFIX to take effect for EAV
> schema? Right now it doesn't affect EAV table names. But one reason I
> could think of, is that some companies have strict policies on what
> should be their database table's prefix. Now they would want their table
> names to be prefixed, no matter traditional schema or EAV schema.
> Thanks
>
> Tiger
>


--

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@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [EMF + Teneo + EAV]: How to customize table names used in EAV schema? [message #516960 is a reply to message #516953] Thu, 25 February 2010 15:45 Go to previous message
tr  is currently offline tr Friend
Messages: 5
Registered: November 2009
Junior Member
Yes, Martin,

I just logged a new ticket at https://bugs.eclipse.org/bugs/show_bug.cgi?id=303919

Thanks

T
Previous Topic:how to use constraints defined by the ecore meta-model in EMF Validation Framework
Next Topic:Multiple Serializations
Goto Forum:
  


Current Time: Tue Apr 23 10:06:06 GMT 2024

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

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

Back to the top