Max - thanks for the quick response - comments inline below
Quote:
Some of the config parameters need to be prefaced with "hibernate." and some of them don't.
No - all of them (if done programmatically) needs the "hibernate." prefix.
If something seemed to work without it was most likely because it was some default.
Aiee - that's worse than what I thought - it demonstrates that not only is the configuration failing silently (which I'll elaborate below) but that in the case of a property where I get the name wrong but try to assign it the default value, the failure will come to light months or years from now when I change the value away from the default, and it will be hard to troubleshoot - making me suspect there's something wrong with the new property value not the property name.
Quote:
It looks like a bug that the programmatic config and the XML config react differently to the same property names.
I consider it a feature of the cfg.xml.
You could argue they should be equal but one could also argue otherwise because of:
1) the reason it is done in the cfg.xml is to make it easier to type/change. same reason we prefer attributes over elements in our xml's. With programmatic access that is not such a big issue.
2) that is how it always worked (backwards compatibility is important and it's extremely easy for you to fix; just put "hibernate." in front ;) thus some might utilize that you can store other properties than "hibernate." prefixed ones.
Yes I argue they should be equal. My expectation is that I should be able to translate whatever I did directly from an XML configuration file into a programmatic configuration. That's exactly what I did, and the code blew up all over. The fact that I have to know there is a distinction means Hibernate is harder to learn.
Aside from that, the distinction is debatable - if allowing users to shortcut the names in XML configurations is a benefit, why isn't it just as much a benefit in programmatic configuration?
Finally, though as you say it is easy to fix - it is a royal pain to troubleshoot. The configuration routine fails to set the expected parameter without warning or error, so you don't know you set the parameter wrong. Later in the program, at some point later, some routine will fail, and you have to relate it back to the "missing" configuration parameter and guess what's wrong. I spent some time yelling at the computer "It's right there! Why don't you see it?!!" before I stumbled on the trick of adding "hibernate." to the beginning of the name.
Note also that the names without the "hibernate." at the beginning came from your "getting started" example in your documentation. Also note there's nothing in the documentation that explains you have to have fully qualified parameter names in programmatic configuration but are allowed to shortcut them in XML configuration. We users have to guess by digging through examples.
You can fix this without breaking backward compatability simply by making the programmatic configuration as permissive as the XML configuration. That way nothing new will fail. Is there really anyone who is taking advantage of the difference between configuration processing to create parameters not prefaced by "hibernate."? That means this can only be done programmatically and not through XML? It's also not documented anywhere.
Quote:
It also seems like there is an opportunity to increase reuse here - possibly there are functionally duplicate code paths between the programmatic config and the file-based config causing the divergence. Or perhaps this is a difference between Configuration (which I used to do the xml-based configuration) and AnnotationConfiguration (which I used to do the programmatic configuration).
What reuse are you referring to here ? They all use the same configuration method today so what is there else to be reused ?
What I mean is to parse the parameter names the same in both places. You must have some code in the parser for XML configuration that handles the parameter names missing "hibernate.". Reuse this same code to parse the programmatic configuration parameter names.
Quote:
btw. you keep mentioning "path" which for me normally refer to file or url paths where as you only mention names
Sorry - I meant property name. Since they are qualified with dots, they seem like "paths" to me. I'll be more careful with my lingo from now on ;)
Quote:
I was going to write up a Jira issue on this, but read on the site that you guys require us to write a post to this forum and get permission before filing a bug? That seems bizarre, but here it is. Oh noble foxes guarding your own henhouse, is it OK to file a bug?
:) if you knew how many bogus bug reports we get then you would not find it bizarre. Plus we don't say you should ask for permission; we simply say you should discuss the issue on the forum *before* you put it in jira since *alot* of the "bugs" comes from misunderstanding or simply not knowing how a feature is/should work.
To your particular issue then I would not call it a bug that the Configuration does not autoprefix the properties.
Hey - consider it the second-sincerest form of flattery that your wonderful work has brought a flood of unreasonable demands from hordes of us clueless idiots. ;)
But - though I was semi-kidding about the foxes guarding the henhouse, I'm also semi-serious. If there is a lot of misunderstanding about a feature, then that indicates that the feature could be made more intuitive and easier to use. This seems so obviously a bug to me I wouldn't hesitate for a minute filing a Jira. It's definitely not a high-priority bug, but it is a usability problem, and the documentation could be better whether you fix it or not.
How about this - if I offered to fix the problem, and made the programmatic config act the same as the XML config, would you accept it as a fix? That way I'm not burdening you with the work. Or is preserving the current undocumented behavior more important?
- John