Previous Entry | Next Entry

"No Metadata Hell" HAHAHAHAHAH

  • May. 12th, 2008 at 11:18 AM
metal
So, now that Nexus Wars' Straylight version has landed, and things have started to calm down, I have decided to begin thinking about the next level of optimizations and so forth.

This means, really, the use of Hibernate. And since I don't feel it is wise to just "drop in" a radical change in datasource management to a hundred-thousand-line codebase, I'm starting a new, small, toy project (a "to-do" list web-app that I can use through the iPhone).



My first complaint:

Hibernate's *documentation* claims that it is a way to "escape the metadata hell that often goes hand in hand with java frameworks."

Okay, so. No.

Quite the opposite. EVEN IF WE IGNORE the arcane weirdness of trying to even get it to run in the first place, you still have to create xml metadata mapping files for every fucking class. So it seems to me that we're actually increasing metadata hell by an exponential degree rather than decreasing it.

Now, I will say that this:

	public User create() {
		Session session = getSessionFactory().openSession();
		Transaction tx = session.beginTransaction();
		session.save(this);
		tx.commit();
		session.close();
		return this;
	}


is far, far sexier than this:

    public User create(Connection conn) {
        PreparedStatement ps = null;
        PreparedStatement liid = null;
        ResultSet rs = null;
        try {
            ps = conn.prepareStatement(CREATE_SQL);
            ps.setEscapeProcessing(false);
            ps.setString(1, getName());
            // Insert another 50 or so ps.setWhatever() calls here.
            ps.executeUpdate();
            ps.close();
            ps = null;
            liid = conn.prepareStatement(SaveManager.LAST_INSERT_SELECT);
            rs = liid.executeQuery();
            rs.beforeFirst();
            while (rs.next()) {
                long lastID = rs.getLong("lastID");
                setID(lastID);
            }
            rs.close();
            rs = null;
            liid.close();
            liid = null;
            UserManager.getInstance().add(this);
        } catch (Exception e) {
            e.printStackTrace();
            result = false;
        } finally {
            if (rs != null) {
                try {
                    rs.close();
                } catch (Exception e) { }                
                rs = null;
            }
            if (ps != null) {
                try {
                    ps.close();
                } catch (Exception e) { 
                	e.printStackTrace();
                }
                ps = null;
            }
            if (liid != null) {
                try {
                    liid.close();
                } catch (Exception e) { 
                	e.printStackTrace();
                }
                liid = null;
            }
        }
        return this;
    }


Of course, it would be, if it actually fucking worked.

Even getting this shit to work is a pain (and I haven't gotten it to fire off yet). If it can even find the configuration, then it can't find the right database dialect. If it can find that, then it can't instantiate connections. If it can do that, then it can't seem to find the mapping metadata. And now that I've got that solved, it can't bind to the JNDI instance.

And seriously, all I'm doing is making a simple to-do list app since there isn't one on the iPhone. I found one on the web! Already! But it wants me to pay 35 bucks a year to use it via iPhone, and I'm bullheaded enough to think, "Well, I can write my own! Thirty five bucks! Psht. I can do this in about 40 hours of work."

And it really should be that simple. I mean, we're only talking about, like, 3 POJO classes (User, ToDoListCategory, ToDoListEntry), maybe 8(?) Action classes (CreateAccountAction, LoginAction, AddEntryAction, EditEntryAction, CreateCategoryAction, EditCategoryAction), about 5 jsp files, and some small graphicalization thingers.

It should really be The Perfect Project to learn this with. And yet, the documentation I can find all appears to be the same cut-and-paste crap from the same things - and they're all out of date. This "awesome" book I got six months ago is totally wrong about a lot of stuff because it's all about version 2 and the current release is version 3.

So frustrating. And I haven't written a line of HSQL yet.



Anyways. At least it's not Perl.

Tags:

Comments

[info]ultraswank wrote:
May. 13th, 2008 05:18 am (UTC)
Hibernate is just one of those frameworks I never got the point of. Troubleshooting what's breaking between your java and your db is already such a pain in the ass, it doesn't seem like throwing a bunch of XML into the mix is really going to solve anything. Sure the JDBC syntax is messy, but thats why you sequester it all off into its own containing class so you never have to look at it.
[info]evilheff wrote:
May. 13th, 2008 05:32 am (UTC)
wtf
dont smack-talk perl, man. It can hear you.