-->
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.  [ 2 posts ] 
Author Message
 Post subject: Hibernate Reverse Engineering for cross schemas ref in MySQL
PostPosted: Mon Oct 12, 2009 3:10 am 
Newbie

Joined: Mon Oct 12, 2009 2:20 am
Posts: 2
Hello, I am new to Hibernate
I was working on 2 web applications where they shared some data such as "User" table.

So, I created schema for each applications and a schema for shared data in MySQL , lets take it : msns, msns1, shared
I assigned all authority of these schemas to a single user
Assume that those schema have these tables
msns: table1
msns1: table2
shared: user

msns.table1.userid will cross schema referencing shared.user.id
msns1.table2.userid will also cross schema referencing shared.user.id

In hibernate.cfg.xml, I will have this:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
  <session-factory>
    <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
    <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
    <property name="hibernate.connection.url">jdbc:mysql://192.168.1.147:3306/msns</property>
    <property name="hibernate.connection.username">msns</property>
    <property name="hibernate.connection.password">msns</property>
    <property name="hibernate.current_session_context_class">thread</property>
  </session-factory>
</hibernate-configuration>


Now here is my problems:

1. Is there other way to access other schemas regardless which default schema at the connection URL.
When I tried to create the hibernate.reveng.xml, it only allowed table selection from schema "msns", how should i manually edit it to include selection tables from "msns1" and "shared"?

2. Even I able to select tables from "msns1" and "shared", is Hibernate able to generate the proper relationship POJO class and Hashmap?
I tried reverse engineer with seperate hibernate.reveng, table1 has userid as Interger datatype instead of having it as User class?

3. Schemas in mysql refer as database? catalogs is a collection of schemas/databases? this really make me confused during selection of table with
Code:
<schema-selection match-catalog="">
vs
<schema-selection match-schema="">


4. I heard Hibernate Shard will work on this, anyone can provide suggestion on this?


Top
 Profile  
 
 Post subject: Re: Hibernate Reverse Engineering for cross schemas ref in MySQL
PostPosted: Tue Oct 13, 2009 3:40 am 
Newbie

Joined: Mon Oct 12, 2009 2:20 am
Posts: 2
Simple question : It is possible for Hibernate to map association over cross database/schemas references table?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.