Wednesday, May 27, 2009

CMD replacement with some nice features

Just found out how much I dislike the standard Windows XP command prompt (cmd.exe).

So, found project named Console. Here's brief list of its features:
  1. Support for tabs
  2. Transparency (don't think anyone _needs_ this really, but, anyway - that's a feature)
  3. Can make long lines unwrapped. But did not find a way to scroll to the right :)
  4. Good fonts from the start :)
  5. Lines selection model instead of box selection model in cmd.
And that's really strange:
  1. Yes, it supports resizing, but does not support maximization. I found this weird

Generally speaking, this is useful, especially when used together with UnixUtils.

Tuesday, May 26, 2009

GWT FlexTable bug

Just faced a complex and really bad bug with GWT's FlexTable.

It tends to forget about the cells removed! So, if I remove some cells, and then add some more, the old ones randomly appear.

Problem is that I was developing really complex layout with dynamic cell manipulation and hard use of rowspan/colspan. And spent 4 hrs fixing algorithm :( :( :(..

Technical details
  • Methods FlexTable::clearRow() and FlexTable::clearCell() seem to be broken (at least in GWT 1.5). They do their job, but sometimes deleted cells reappear in table. That's frustrating.
  • This is also stated on the Google code tracker : Issue 1766
  • I avoided this problem by replacing calls to clearRow and clearCell to FlexTable::clear(). Yes, that's a heavy solution - but it did fit for me :)

Tuesday, May 19, 2009

Hibernate IN statement

Problem with hibernate selections of ranged values (sets)

update (2009-05-19):
Thanks to Denis Tsyplakov, found HQL in expression :D. Problem comlpetely closed. So, one should better user HQL, not criteries.


Disclaimer: there's nothing really new in this article. You might know everything which is written here. This posting is mostly for myself and people facing the same problem (with memory :) I just forgot how this should be done. Thanks to colleagues returning me to the right way. Here is the problem described:
  1. We have a mapped Hibernate entity.
  2. This entity has some field. :) For example. Let it be some enumeration (status?).
  3. We need to select the entities with several statuses.
Here's example of such entity:

@Entity
@Table(name="entity")
public class Entity {

@Id
@Column(name="entity_id")
private long id;

@Column(name="entity_status")
private Status entityStatus;

// Getters and setters.

}

and example of the enumeration:
public enum Status {
STARTED, COMPLETED, NOT_STARTED;
}

We need, for example, select all STARTED and COMPLETED entities, not touching NOT_STARTING.

Solution
There are 3 valid ways I see:
  1. We make a query for STARTED entities, and then other query - for NOT_STARTED. After the results are gathered the result objects are mixed.
    Cons: you'll need to do N queries for N statuses. Quite bad, isn't it?
    Pros: don't really know. Maybe, it's simple? ;)

  2. We construct a query, with OR statement in the middle. That how it should look like:

    select e from Entity e where e.status=1 or e.status=2
    I'm using the 1, 2 numbers and not the enum names especially to make statement less complicated.
    Cons: single query, but static. That means that if you need to form the list of statuses to load at runtime (set of checkboxes?), you'll need to glue HQL. And any query gluing smells very bad.
    Pros: simple, and if you are sure the list of statuses to load would never change... if you are SURE.



  3. And the least one I see. We may perform selection using the Criterion Hibernate API, not the query language. The 'query' itself would look like the following code:

    List statusList = new ArrayList(); statusList.add(Status.STARTED); stausList.add(Status.COMPLETED);
    Criteria c = session.createCriteria(Entity.class). add(Restriction.in("status", statusList)); c.list(); // get the list of entities with corresponding status.
    Cons:uses Criteria API, which really is a code. So, if you plan to store HQL queries in a (properties) file, this way is not for you.
    Pros: fast, simple and dynamic. That's what I left with.

Tuesday, May 12, 2009

Splitting blogs

So, I decided to split the blog to two separate 'threads'.

This leaves for technical things, as well as some interesting reports, everything related to work, IT, outsourcing, java and Unix. And the new one (http://way-up-only.blogspot.com/) is designated for personal things.

Yes, the new one is cyrillic. :)

So - welcome!

The first 'real' posting will be about our trip to Crimea mountains. Soon, really soon... :)

I'm back!

Just got back from the trip to Crimea mountains. That is really cool!
Photos will be soon.

Also, I'm feeling this blog became less technical. So, I think, I'll split it to two :)

Wednesday, May 6, 2009

PdfChm - find the freshest books for FREE

The PdfChm resource is a large collections of books on programming, science, maths, law, photography and lots more. There are even books on crime.

So, enjoy. Registration is free, but you can download no more than 2-3 books per day.

There are pdf, chm :) , ps, djvu, and other formats available.. Readable anyway.