-->
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.  [ 16 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Writting a Custom LDAP Persister
PostPosted: Thu Sep 11, 2003 11:01 am 
Newbie

Joined: Thu Sep 11, 2003 9:59 am
Posts: 2
Hello,

I'm having troubles trying to write my own persister to be used with all of the power of hibernate, with a ldap storage environement.

First lets explain what I did to get it working :

  • I wrote an ldap component that connects and retreives the information I need in my ldap data store.
    This worked well as I tested it with a TestCase, I'm shure it still
  • I wrote (from a copy of CustomPersister given with hibernate and its documentation) an hibernate LdapPersister that only (for the moment) loads a unique entity (by id)
    This worked well and still does for the same TestCase reason
  • I then wrote the test that should work with call from a session from hibernate using my persister
    And this doesn't work :(

    Why doesn't it ? My problems are recurently the same, it always comes a point where I meet a JDBC requiement. Of course this does not reach my goal to crate this persister with no JDBC stuff surounding. I will always be using some SGBD in the final developpements but I don't want to meet those JDBC thing in my ldap persister.

    I created many defferent type of configurations and finally ended up with some manual config java coded to ensure I did put exacly what I wanted :
    Code:
       Configuration config = new Configuration().addFile(
           "g:\\projets_java\\frameworkbdpme\\classes\\User.hbm.xml");
       Properties properties = new Properties();
       properties.put("connection.driver_class",
                 "COM.ibm.db2.jdbc.net.DB2Driver");
       properties.put("connection.url", "jdbc:db2://-----------");

       config.addProperties(properties);
       PersistentClass persistentClass = config.getClassMapping(Utilisateur.class);
       sessionFactory = config.buildSessionFactory();

       Class.forName("COM.ibm.db2.jdbc.net.DB2Driver");
       Properties sqlProperties = new Properties();
       properties.put("username", "****");
       properties.put("password", "*****");
       java.sql.Connection connection = DriverManager.getConnection("jdbc:db2://-----------", sqlProperties);
       Session session = sessionFactory.openSession(connection);

       return session;

    This would work be of course I don't want this connection to a SGBD to be present.

    and here is the call to load (
    [code] public void testLoadHibernate() throws HibernateException, SQLException, ClassNotFoundException
    {
    Serializable id = new LdapId("****", "****", "****");
    Object optionalObject = null;
    LockMode lockMode = LockMode.NONE;

    Session session = getSession();

    Utilisateur user = (Utilisateur) session.load(Utilisateur.class, id);
    assertNotNull("Impossible de retrouver *****", user);
    assertEquals("Mauvais nom r


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 11, 2003 12:05 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
(1) Have you looked at the custom persister in the test package?
(2) If it were _me_, i would probably NOT go down this path. I can still have a ldap persisted object with relationships to hibernate objects, just by using a UserType. But if you want to use Hibernate's property management machinery, I suppose it is reasonable.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 12, 2003 4:00 am 
Newbie

Joined: Thu Sep 11, 2003 9:59 am
Posts: 2
First of all thank you Gavin for this quick answer.

gavin wrote:
(1) Have you looked at the custom persister in the test package?

Indeed, I used this class as a skeleton to write my own.

gavin wrote:
(2) If it were _me_, i would probably NOT go down this path. I can still have a ldap persisted object with relationships to hibernate objects, just by using a UserType. But if you want to use Hibernate's property management machinery, I suppose it is reasonable.

I'm sorry but I'm don't have a clue on how to anderstand this. Could you show me the way so I can then decide to climb it or decide not to.
What I andersood there is, make your own ldap persitence/mapping with no link to hibernate engines and then for any linked HibernateMappable Object use hibernate as usual. Is this what you explaining ?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 12, 2003 4:59 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Yes, i think you have understood me.

A UserType may be used to manage a relationship to a non-Hibernate object.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 16, 2003 4:22 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
Try to implement JDBC driver and "dialect" for hibernate, it must be more simple and reusable. It must not be a problem to find opensource SQL parser.


Top
 Profile  
 
 Post subject: LDAP
PostPosted: Mon Oct 06, 2003 9:45 pm 
Newbie

Joined: Mon Oct 06, 2003 5:35 am
Posts: 9
Location: Perth.au
Hi,

I would be interested in a means of using Hibernate to manage LDAP too.

I expect the way to go is: -

A) Create an LDAP dialect to allow the use of hibernate

B) Create a middlegen plugin to access the LDAP schema port, download the available schema and generate mappings.

BUT

I have used my own LDAP access rather than go through JDBC, the SQL is relationship orientated and LDAP is heirarchical.

The question I have is if I use SQL/JDBC will I loose the reason I am using LDAP in the first place ?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 07, 2003 4:21 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
I don't see any "good" way to integrate Hibernate with LDAP and no particular reason to do so.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 07, 2003 8:42 pm 
Newbie

Joined: Mon Oct 06, 2003 5:35 am
Posts: 9
Location: Perth.au
Fair enough Christian

I have inherited an LDAP with a legacy application, the vendor of the application does not sell RBDMS systems so they use the Directory Server as the main repository of data, it sits half way between the static data LDAP is design for and the constantly updating database data.

LDAP should be hierarchical but with the new applications I need to maintain an increasing number of relationships between LDAP objects which is proving a pain. I would be nice to be able to run queries rather than filters and have the relationship managed for me.

At the end of the day, LDAP is just a specialised database.

Cheers

Jon K


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 08, 2003 3:48 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
It is not a database. It doesn't support any ACID criteria and it's a hierarchical mess. You should definitely redesign your data structures and export them to a "real" database. This is a one time effort, but worth the time.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject: No
PostPosted: Wed Oct 08, 2003 4:25 am 
Newbie

Joined: Mon Oct 06, 2003 5:35 am
Posts: 9
Location: Perth.au
Can't do that, you have missed the word
Quote:
legacy

I wanted to, I have nagged, I have even had a tantrum and screamed and screamed and screamed until I was sick but it means rewritting a major system (which no one will pay for)

It's a database in terms of having ISAM libraries at the heart of it but does not have the layers that Oracle has for concurrency and transaction management, ... - Hence the write once - read many nature of the beast.

I think LDAP has it's place, good place to store application configuration data.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 08, 2003 6:33 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Hibernate is an Object/Relational Mapper. You got the wrong tool...

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 08, 2003 6:36 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
I don't -necessarily- agree with Christian here; it is certainly possible to write a custom persister that persists objects to LDAP. But you won't have any querying capabilities. Only load by dn.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 08, 2003 8:53 pm 
Newbie

Joined: Mon Oct 06, 2003 5:35 am
Posts: 9
Location: Perth.au
Doesn't CASTOR do both ?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 08, 2003 8:56 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
I don't see any advantage with an LDAP persister in an ORM tool. Where is the "relational" part? What about transactions, concurrency? There's a perfectly valid Directory API in Java, use it. Add a DAO layer on top if you are not happy with it.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 02, 2004 5:48 am 
Newbie

Joined: Tue Sep 02, 2003 10:35 pm
Posts: 9
S


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 16 posts ]  Go to page 1, 2  Next

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.