-->
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.  [ 6 posts ] 
Author Message
 Post subject: Architecture question
PostPosted: Thu May 26, 2005 12:54 am 
Regular
Regular

Joined: Tue Nov 09, 2004 5:15 pm
Posts: 100
Hello All,

We currently have a Java based non-hibernate server and Mac OS X native client. We are planning to replace the non-hibernate server to hibernate one. Currently, our client (non-java) sends requests in XML format. For example, say i've table called TABLE1 and it has 10 attributes. In order to create a new entry in that TABLE1, the client will send "SAVE" txn with all 10 attribute values in XML format. Our server generates the corresponding SQL Query and persists the table using JDBC APIs.

When we migrate to hibernate based implementation, we would like to still support the XML based requests from the client. In this new implementation, we'll have a POJO for TABLE1 and there will be a stateless session bean which will persist the POJO. The problem is that, when the XML request comes to the server, we should identify the following:

1. Which POJO(s) this request maps to. It could be that one POJO has one-to-many relationship and references to other objects.

2. Which attributes from the XML request maps to which property(attribute) in POJO. Currently, we've some XML based mapping file that represents the schema for TABLE1, various actions supported for this table (find, save etc). Please note that some of the actions need to query multiple tables using join and we've no DB Views for that. The XML mapping file is flexible to support views.

If we choose to maintain some mapping file to map the XML request to the attributes of POJO, i'm afraid it would be a duplicate of annotations or XDoclet based .hbm.xml mapping files.

As our client is NOT a java client, it can't create POJOs and populate them either. As this would be a common requirement for anyone who want to write a THIN CLIENT and handle creating appropriate POJO and persist in the DB using hibernate, i would like to get opinion from this forum as we've several experts in this forum.

Thanks for any input in advance!


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 26, 2005 7:40 pm 
Regular
Regular

Joined: Tue Nov 09, 2004 5:15 pm
Posts: 100
Hi All,

As i've not heard from any of you, i thought the information that i've provided is not enough. hence i'm giving some more information on my requirements.

In the current architecture, when the client wants to find an object say X where the attributes Y and Z are known, the request will be as follows:

Code:

<Query Object="X" Action="Find">
       <Y>test</Y>
       <Z>test1</Z>
</Query>


Please note that it's a Mac OS X native cocoa client and it's non-java.


When this XML request is received, we know the table name from the Object name and the attributes Y and Z will be the columns in that table X. Hence we'll generate the query and return the results.



In the new architecture using Hibernate using the same non-java client, it's going to send the same XML request. But in this case, One table X which has several attributes as it was NOT object oriented, will be represented by a POJO X. Instead of having all the attributes in the same POJO, we'll introduce new POJO's and X will have reference to these POJOs.


Currently the attributes names sent by the client is directly mapped to the attribute names of the table which will NOT be the case in the new architecture. So what is the best way to map the attributes sent by the client to that of the POJO???

I'm tempted to introduce a mapping file which will provide this information but i'm afraid this will be a duplication of the hibernate mapping file or annotations for that matter.


It's NOT common to have the non-java client talking to java server. But as there are many experts in this forum, i would greatly appreciate their input/suggestion on this.

Thanks in advance!


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 26, 2005 8:10 pm 
Newbie

Joined: Thu May 26, 2005 6:31 pm
Posts: 19
I think to support a non-java client is a very common requirement. The scope of the discussion is much bigger and for my understanding, it does not have much to do with Hibernate.

Hibernate is just a persistence technology and should not have much influence or impact on the way you design your overral system architecture.

If you design your system as a tiered architecture, hibernate should be encapsulated inside the intergration tier.

Based on my limited knowledge of your requirement/system, I think you should definitely move to the direction of web services.

What you already have (xml based request), is kind of a home-grown web service implementation, which is very common within a legacy system.

The basic idea of your new architecture should be:
web service tier - take user request, using web service binding or mapping framework, e.g. xmlbeans, to map the request into java request. Mapping in between xml request and POJO (u mentioned) happens here. Web services tier is just a wrapper to your business tier.

business/service tier - u can either use POJO or stateless session bean to implement this tier. It handles transaction for u and invoke the integration tier.

integration tier - here's where hibernate belongs. Using hibernate to persist/retrieve the POJOs. Hibernate is replacable by other persistence technologies, e.g. JDBC, JDO, etc.

About the way you implement your POJO, it is just design details. Hibernate is very flexible to support the whichever way you design your POJO, e.g. inheritance, granularity, etc.

Hopefully, it will help.
Derek


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 27, 2005 12:50 am 
Regular
Regular

Joined: Tue Nov 09, 2004 5:15 pm
Posts: 100
Thanks for your input dshen. I'm not sure if using xml binding tools would help us. If we do use xml binding to create Java Beans which is also a POJO, we'll have two set of POJOs. Also, the XML request sent by client is more than just attributes.

For example, the client could send an XML req as follows:


Code:
<Query Object="X" Action="Find">
    <CRITERIA CASESENSITIVE="N" WILDCARD="Y">
                        <GROUP JOIN="AND">
                                <PRIORITY OPERATOR="EQ" BIND="Y">:PRIORITY</PRIORITY>
                                <TICKETSTATUS OPERATOR="EQ" BIND="Y">:TICKETSTATUS</TICKETSTATUS>
                                <RANKING OPERATOR="EQ" BIND="Y">:RANKING</RANKING>
                                <PRODUCTCATEGORYCODENAMELOWER OPERATOR="LIKE" BIND="N">Espresso</PRODUCTCATEGORYCODENAMELOWER>
                        </GROUP>
                </CRITERIA>
              <VARIABLES>
                        <PRIORITY IGNORED="N">3</PRIORITY>
                        <TICKETSTATUS IGNORED="N">2</TICKETSTATUS>
                        <RANKING IGNORED="N">999</RANKING>
                </VARIABLES>

</Query>


The above xml request means that we've to find in object X with the given criteria (where CLAUSE as indicated by GROUP which could have AND or OR). We also have operators for the attributes which says that, we need to find X where the Priority attribute == 3 (we are using bind parameters as represented by VARIABLES) AND TicketStatus attribute == 2 etc...

Instead of EQ operator, we could use GT, LT, BETWEEN, IN or any valid SQL operator in the input. In this case, the XML request may not just map to some Java Beans.

Even if we manage to parse the XML request which we are doing as in our current phase, the next problem is to generate HQL for hibernate.

As this is a common requirement that a client could have forms which needs to perform complex queries using variable OPERATORs, i would greatly appreciate some suggestions on this line.

Thanks in advance!


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 27, 2005 1:15 am 
Newbie

Joined: Thu May 26, 2005 6:31 pm
Posts: 19
The requirement/use case given in your example is more like an advanced search feature.

You can consider to use Hibernate Criteria to implement it. Basically you need to transform the user request into some kind of query in an object oriented view. If Hibernate Criteria can fulfill your reuirement, there's no need to reinvent the wheel.

The basic idea is on the client side to build the criteria object. Invoke the web service. On the server side, construct the criteria object and query against hibernate.

About the POJO, not necessary you need two set of POJO. If possible, always use the same set of value objects (POJO) cross all tiers.

When implement the advanced search feature, security is a major concern. The query sent through the client needs to be checked before executed.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 27, 2005 2:18 am 
Regular
Regular

Joined: Tue Nov 09, 2004 5:15 pm
Posts: 100
Thanks dshen. My client is not an written in any OO language. It can't construct any POJOs. That's why it's sending just XML Request.


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