jQuery in Action, 2nd edition*
The moose likes Object Relational Mapping and the fly likes Shared mysql database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Shared mysql database" Watch "Shared mysql database" New topic
Author

Shared mysql database

Johann Spitz
Greenhorn

Joined: Feb 21, 2005
Posts: 11
I have a hibernate web application (Tomcat) that already features a user management (complete with userlevels etc). Now I want to create a new application that uses its own database schema *but* - is able to use the User data from the other application.

This way I wouldn't have to create yet another user management. Is something like this possible with hibernate/mysql? Is there a solution to this at all?
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Two schema's == two SessionFactories. But if your new schema uses the data in this 'user' schema, why is it not part of the same schema?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Johann Spitz
Greenhorn

Joined: Feb 21, 2005
Posts: 11
Two schema's == two SessionFactories. But if your new schema uses the data in this 'user' schema, why is it not part of the same schema?


Okay, i will need two SessionFactories if I want to use the old schema. Thanks, that may help!

But I don't really understand your second question. I built one application that has a full user management. Now I want to build a second, totally unrelated app, that pulls data from the first one - why should I want to mingle the two into one database?

The problem here seems to be that I need to add relationships to the User object. What if I would do something like


where Toys is a java.util.Set that is mapped to the user one-to-many I guess I wouldn't be able to do that, would I?
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


totally unrelated app

What I mean is if these are truly unrelated, then the schemas would be completely seperate. If they were totally unrelated then the second one would use no data from the first. If they are not, then perhaps one schema is a more accurate way to model your data?

But your follow-up post suggests you want to export data from the existsing app into your new app - am I right? i.e. you have a table called table_a in schema 1 which has data you want to move to a table called table_a in schema 2? If that's the case, you might consider some backend export script rather than putting it in your app. Just a suggestion - you (obviously) have much better visibility of what your requirements are than I do.
[ April 05, 2005: Message edited by: Paul Sturrock ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Shared mysql database