-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Mapping of Navision MS SQLServer tables
PostPosted: Wed Feb 16, 2005 7:39 am 
Beginner
Beginner

Joined: Tue Aug 17, 2004 5:06 am
Posts: 46
Hibernate version: 2.1

Name and version of the database you are using: MS SQL Server with Navision tables

I am confronted with a rather unusual legacy database layout, where table and column names contain Umlauts, blanks and everything evil (i.e. "[Alle Bonitätsdaten].[KundenNr. des Antragstellers]"). The database layout is a fact that I can't change.
Those tables are generated by Navision, a CRM product that is now owned by Microsoft.
Mapping the table and column names is no problem, since I can easily escape them with square brackets.

My first question is: is there any generic support for escaping *ALL* column and table names in Hibernate. Currently I have to do this by hand for hundreds of mapped columns, which is not very amusing.

But the real problem is that some tables are duplicated in the database. This is a feature of MS SQL Server (?) that can be used to isolate tables between mandators. The names of these tables are prefixed with the mandator's name and a dollar sign (mandator$table).

I.e.:
customer1$orders
customer2$orders
...

The tables have absolutely the same structure, but from JDBC's the point of view different table names.

So my second question is: how could I possibly map these tables in Hibernate without having separate POJOs for every table (which would force me to apply code changes when a new mandator arrives) ?
I just want a union over all tables. Is it possible to map the same object to different tables or should I try a view on a union of all these tables (the good thing is: i only have to read the tables) ?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 16, 2005 8:29 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Take a look at NamingStrategy, I _think_ you can escape there.

Also you can use schema/catalog for your $ problem I think


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 16, 2005 9:17 am 
Beginner
Beginner

Joined: Tue Aug 17, 2004 5:06 am
Posts: 46
michael wrote:
Also you can use schema/catalog for your $ problem I think


What exactly do you mean with 'schema/catalog' ?

Of course I could set the default schema name to some mandator but I need *ALL* those similiar tables mapped in the same session. Can this be done with setting the schema ?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 16, 2005 9:35 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
You can also set the schema on every class individually.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 17, 2005 6:18 am 
Beginner
Beginner

Joined: Tue Aug 17, 2004 5:06 am
Posts: 46
michael wrote:
You can also set the schema on every class individually.


Is it possible to set the schema for a class and a single request ? Otherwise I would have to create a specific bean for every customer and map it to another schema. This will lead to maintenance nightmare.

I know the client's name at the time when I have to query the database, so I would like to decide on the schema of a mapped class at runtime.

I.e. something like:
if (customer_name.equals("C1")) {
session.<setSchemaForBean>(AccountBean.class, "pdo.customer1$");
} else if (customer_name.equals("C2")) {
session.<setSchemaForBean>(AccountBean.class, "pdo.customer2$");
}

Is something like that possible ?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.