Great!!! . Send it me NOW .
I already handle that using the "AutoGeneratedKeys" class. Please see the Postgresql implementation. It consists on creating a query that will get the last generated value of a sequence.
Nice. What problems you've found?
I had a look at it. If I understood correctly, you are running a query (SELECT CURRVAL('sequence')) to fetch the generated PK value. There is no such TX-safe equivalent in Firebird nor Oracle.
And for Mysql, you are using the JDBC3 feature (prepareStatement(stmt, Statement.RETURN_GENERATED_KEYS)) which is not supported by many JDBC drivers, like the Firebird and the Oracle ones.
All of them are related to the admin control panel:
- In Users panel, the Insert button is broken
- In Groups panel, creating a group that does not have Top Level Group as parent breaks the screen
- there is no proper way to exit the admin panel
hmm.. in Oracle
SELECT your_sequence.currval FROM dual
doesn't works? ( of course is not 100% "safe", but we can always sync that ).
Problem is that it's not safe: if another SELECT your_sequence.nextval is called before your call to SELECT your_sequence.currval, you're catched.
How can you sync that ?
I just changed JForum to support FirebirdSQL.
everything should work (more or less) fine and I can provide a patch to be applied on RC4.
Unfortunately I encountered some design flaws in your persistence engine that will cause problem with firebird and other databases that don't support getting generated PK after insertion, like Oracle.
There are also quite some bugs that I've found here and there.
Interested ? Just let me know.
What do you think?
GreenEyed wrote:What I usually do is generate the keys myself, instead of letting the db generate it, so you know the key in advance and you don't depend on the support of the DB for sequences, autonumerics or retrieving the last generated key.
XDoclet has a unique ID generator that can be used for that, which generates 32char IDs. They don't look as good, meaning simple, as counters, but they are easier to manage.
Just an option.
GreenEyed wrote:What I meant is that I borrowed the technique that is implemented in XDoclet, not that I use XDoclet for that ;). I use it for other things though.
I've been using it for years and so far I have never come across a single conflict.
The technique you explain is interesting, even though I'm not sure I like creating a table and making it the bottleneck of the creation of all database objects.
But using the generated ID for sorting is something I would not do. The best PKs are usually the ones that have absolutely no meaning but just being an ID.
This is not a bottleneck. Imagine - how many simultaneous new user/posts you can have?
Very unlikely more than 1-2 a second.
Iven if it will be 10000 new users/post a second (you will never get such traffic) this technique would work OK.
Anonymous wrote:I am not sure, but as far as I remember JForum uses id for something like I mentioned.