-->
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.  [ 26 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: why cant subclass have a comment element
PostPosted: Mon Nov 28, 2005 8:04 am 
Beginner
Beginner

Joined: Thu Nov 24, 2005 2:58 pm
Posts: 21
It seems the subclass element is not allowed a comment element unlike class, join, joined-subclass and union-subclass. Is this intentional or not?

We're using the hbm comment tags to produce docbook schema documentation and I want my derived entities to have distinguished comment tags even if its table-per-heirarchy.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 28, 2005 9:13 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
hmm - the comment element applies to the underlying table...a subclass is the same table as the class.

...docbook schema documentaiton ? Anything you would like to incorporate for the hibernate tools html based schema documentation ? ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 28, 2005 11:43 am 
Beginner
Beginner

Joined: Thu Nov 24, 2005 2:58 pm
Posts: 21
hi max,

thanks for the reply however ;)

max wrote:
hmm - the comment element applies to the underlying table...a subclass is the same table as the class.


I know the table is the same when you use subclass but the subclass is still a different entity. Is there a problem with giving that its own comment tag? I guess I'm thinking of it a little like a class level javadoc. I want to be able to provide a specific subclass comment. I dont know what if anything in Hibernate this might break.

max wrote:
...docbook schema documentaiton ? Anything you would like to incorporate for the hibernate tools html based schema documentation ? ;)


Not sure I quite follow you max. I've built docbook toolchain that parses our HBM mapping files and renders a database structure document (pdf or whatever). Its just a cheap way to harvest & synchronise our db schema documentation.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 28, 2005 12:15 pm 
Beginner
Beginner

Joined: Thu Nov 24, 2005 2:58 pm
Posts: 21
hi Max,

I guess you're talking about <hbm2doc>. I dont use eclipse so hadn't seen this exporter before. Still any thoughts on the subclass comment tag?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 28, 2005 12:22 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
why does anyone suddenly think that our ant tasks require eclipse !? It does not! ...

<hbm2doc> is something that would be natural to look at and see if it fits your needs - and if it does not and you want more sexy things then I would be more than glad to receive contributions/ideas/etc in our Jira.

And regarding <comment> then it is a table specific thing and for class descriptions we use <meta attribute="description">stuff that is here goes in javadoc when usuing hbm2java</meta>

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 29, 2005 4:18 am 
Beginner
Beginner

Joined: Thu Nov 24, 2005 2:58 pm
Posts: 21
cheers max that clears it up. i'll take a look at our docbook stuff later and play with the hbm2doc task too.

thanks again


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 29, 2005 7:55 am 
Beginner
Beginner

Joined: Thu Nov 24, 2005 2:58 pm
Posts: 21
another Q max,

from either a Table or Column object retrieved from the Configuration can I recover what derived entity the column was part of?
Code:
<hibernate-mapping default-lazy="false">
    <class name="com.model.A" table="A">
        <property name="created" type="java.util.Calendar" column="CREATED" access="field"/>

    <subclass name="com.model.B">

        <property name="aNumber" type="java.lang.Long" column="SOME_NUMBER" access="field"/>
    </subclass>
    </class>
</hibernate-mapping>

In my generated docs I'd really like to denote that property 'aNumber' is part of type B and not A and that 'created' is part of A and is present in row types of A and B. Sure I could make this explicit in the comment about the B properties but I'd be repeating it for every one.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 29, 2005 8:28 am 
Senior
Senior

Joined: Mon Apr 04, 2005 8:04 am
Posts: 128
Location: Manchester, NH USA
Take a look at the org.hibernate.mapping.Property class -- obtained from Configuration.getClassMapping().getProperty({name})

The Property class has getColumnIterator and getColumnSpan methods that you can use to get information about the mapped database columns for properties on a mapped class or subclass.

If you'd like a code sample, post back - the API is very easy to use, and if you've come this far you probably don't need it :)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 29, 2005 8:39 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
yes, pmularien's suggestion is currently the best way.

I will need to at some point add some utility class that can traverse the Configuration and provide more "reverse-lookup" features like this. e.g.

Property[] getPropertiesForColumn(c)
PersistentClass[] getPersistentClassForTable(t)

etc.

but currently it is not there in public usable form.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 29, 2005 8:43 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
btw. the problems you are working on here is exactly the stuff we have added/want to add to the hbm2doc generation.

It is currently not complete, but it would definitly be appreciated that someone would scratch their own itch and contribute to it (hint hint ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 29, 2005 3:03 pm 
Beginner
Beginner

Joined: Thu Nov 24, 2005 2:58 pm
Posts: 21
pmularien wrote:
Take a look at the org.hibernate.mapping.Property class -- obtained from Configuration.getClassMapping().getProperty({name})

The Property class has getColumnIterator and getColumnSpan methods that you can use to get information about the mapped database columns for properties on a mapped class or subclass.

If you'd like a code sample, post back - the API is very easy to use, and if you've come this far you probably don't need it :)


hi pmularien,

I may have rated too soon ;) I'd appreciate a sample that shows solving the problem posed as I'm lost in the weeds a bit. I had been iterating the table mapping which I now think is the problem as it gives me the flat view of the object hierarchy. I guess the ClassMapping is more appropriate but the javadocs are a tad light and I'm not making much progress.

TIA,

stephen


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 29, 2005 4:10 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
well, if you looked in hbm2doc and the other exporters in the toolset you will find code that iterate this stuff - and while you are at provide improvements ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 29, 2005 4:50 pm 
Beginner
Beginner

Joined: Thu Nov 24, 2005 2:58 pm
Posts: 21
max wrote:
well, if you looked in hbm2doc and the other exporters in the toolset you will find code that iterate this stuff - and while you are at provide improvements ;)


Well Max you're nothing if not subtle. I'd be more than willing to contribute improvements once I know what's happening and what I'm doing but as you don't seem willing to help I cant say when that'll be.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 29, 2005 5:14 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
not willing to help ?
what do you mean ? seriously...

I tell what classes to use and where you can find the exact same code...

Want more precise pointers which only will give you one of many ways of extracting data then look at ConfigurationNavigator, POJOExporter or any kind of Exporter.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 29, 2005 5:36 pm 
Senior
Senior

Joined: Mon Apr 04, 2005 8:04 am
Posts: 128
Location: Manchester, NH USA
smcnamara wrote:
hi pmularien,

I may have rated too soon ;) I'd appreciate a sample that shows solving the problem posed as I'm lost in the weeds a bit. I had been iterating the table mapping which I now think is the problem as it gives me the flat view of the object hierarchy. I guess the ClassMapping is more appropriate but the javadocs are a tad light and I'm not making much progress.

TIA,

stephen


max is pointing you in the right direction, the hibernate tools are probably the main users of all of the metadata APIs and they are fairly easy to read.

That said, there's not really a straightforward way to do what you want (which is what max was indicating). If I read your goal properly, I'd state it like this: "given column X, provide the property and/or class which maps to that column".

The available options in the existing API are -
#1 Get the Table(s) and Column(s) in the schema (you have already found this)
#2 Get the ClassMapping, and the list of Properties for each class (I pointed you at the API for this). From the Property you can get the associated Column(s)

So you'll need to provide the glue between these two APIs - you'd probably iterate over the Tables and Columns (use API #1) , and use API #2 to, given a Table/Column, iterate over ALL Classes and Property objects until you find a matching Table/Column.

It's brute force, but you could do some nice caching and optimization to make it fairly speedy.

That's your only option, if you want to file an enhancement request to the core API to perform a single atomic function (max had suggested some method signatures which would potentially fit the bill), I'd suggest filing a detailed enhancement request in JIRA.

Hope that helps,
Peter


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