Search Results

Search found 3 results on 1 pages for 'cretzel'.

Page 1/1 | 1 

  • Hibernate: Criteria vs. HQL

    - by cretzel
    What are the pros and cons of using Criteria or HQL? The Criteria API is a nice object-oriented way to express queries in Hibernate, but sometimes Criteria Queries are more difficult to understand/build than HQL. When do you use Criteria and when HQL? What do you prefer in which use cases? Or is it just a matter of taste?

    Read the article

  • Loose Coupling vs. Information Hiding and Ease of Change

    - by cretzel
    I'm just reading Code Complete by Steve McConell and I'm thinking of an Example he gives in a section about loose coupling. It's about the interface of a method that calculates the number of holidays for an employee, which is calculated from the entry date of the employee and her sales. The author suggests a to have entry date and sales as the parameters of the method instead of an instance of the employee: int holidays(Date entryDate, Number sales) instead of int holidays(Employee emp) The argument is that this decouples the client of the method because it does not need to know anything about the Employee class. Two things came to my mind: Providing all the parameters that are needed for the calculation breaks encapsulation. It shows the internals of the method on how it computes the result. It's harder to change, e.g. when someone decides that also the age of the employee should be included in the calculation. One would have to change the signature. What's your opinion?

    Read the article

  • Wicket: How to implement an IDataProvider/LoadableDetachableModel for indexed lists

    - by cretzel
    What's the best way to implement an IDataProvider and a LoadableDetachable in Wicket for an indexed list? Suppose I have a Customer who has a list of Adresses. class Customer { List adresses; } Now I want to implement a data provider/ldm for the adresses of a customer. I suppose the usual way is an IDataProvider as an inner class which refers to the customer model of the component, like: class AdressDataProvider implements IDataProvider { public Iterator iterator() { Customer c = (Customer)Component.this.getModel(); // somehow get the customer model return c.getAdresses().iterator(); } public IModel model(Object o) { Adress a = (Adress) o; // Return an LDM which loads the adress by id. return new AdressLoadableDetachableModel(a.getId()); } } Question: How would I implement this, when the adress does not have an ID (e.g. it's a Hibernate Embeddable/CollectionOfElements) but can only be identified by its index in the customer.adresses list? How do I keep reference to the owning entity and the index? In fact, I know a solution, but I wonder if there's a common pattern to do this.

    Read the article

1