Anything that interests me finds place here. Software dominates my interests and hence a good part of this blog as well.
Friday, July 31, 2009
It is the fool who fails to return to the place of his last happiness
"It is the fool who fails to return to the place of his last happiness." - Don't know the author
Monday, July 27, 2009
Wednesday, July 22, 2009
Multilayer validation strategy
The validation logic of an application can be spread across the application. Some logic against the UI, some against Business layer, some against service layer and some against DAO layer.
Labels:
Java
Sunday, July 19, 2009
One difference between chapter 7 vs. 11 bankruptsy
Chapter 7 - Going into liquidation
Chapter 11 - Trying to re-habilitate
Chapter 11 - Trying to re-habilitate
Wednesday, July 15, 2009
Simple APIs responsibilities on arguments
public Student createStudent(Student student, Couse course)
Lets say the responsibility of this API is to save the student and return the saved version back (the saved version will have the key).
Some implications of this API is that
- If there is a failure, student and course objects should be left un-touched. If there were changes made before the createStudent() failed, all those changes should not be visible to the client of this API. This can be done by taking a copy of the student and course and letting createStudent() operate on that copy. That way if there is a failure, then the original student and course object remain intact.
- If the operation succeeds, the client of this APIs would usually require that all changes made by createStudent() be reflected in student and course. To achieve this, after all createStudent operations complete successfully, overwrite the copy that was made at that start of the call back into student and course.
Labels:
Java
Saturday, July 11, 2009
Saturday, July 04, 2009
Do what you can do
Forget about your lists and do what you can because that’s all you can do. Phone up the people you miss and tell them you love them. Hug those close to you as hard as you can. Because you are always only a drunk driver’s stupidity, a nervous shopkeeper’s mistake, a doctor’s best attempts and an old age away from forever. - Julie
My hapiness and self worth
Don`t rely on someone else for your happiness and self worth. Only you can be responsible for that. If you can`t love and respect yourself - no one else will be able to make that happen. Accept who you are - completely; the good and the bad - and make changes as YOU see fit - not because you think someone else wants you to be different.
- Stacey Charter
- Stacey Charter
Time it takes to get something done
Don’t let the fear of the time it will take to accomplish something stand in the way of your doing it. The time will pass anyway; we might just as well put that passing time to the best possible use
- Earl Nightingale
- Earl Nightingale
HQL notes
Case IN-sensitive
except names of classes and their properties
- Doubt: "This manual uses lowercase HQL keywords. Some users find queries with uppercase keywords more readable, but this convention is unsuitable for queries embedded in Java code." - why is this so?
- Doubt: "This manual uses lowercase HQL keywords. Some users find queries with uppercase keywords more readable, but this convention is unsuitable for queries embedded in Java code." - why is this so?
the from clause
minimum query is from Student - selects all instances of Student class. By default auto-import is true. So class names do not have to be qualified with the package name. If auto-import is turned off (false) then this query must be written as from com.xyz.Student
To refer to Student in other parts of the query, an alias must be assigned to Student. from Student as student assigns student as an alias for Student. The "as" is optional. So the previous alias association can be written as from Student student. Its a good practice to start alias names in lower case as this is in-line with java coding standards for naming variable names.
- from Student as student, Department as department gives a cartesian product of all students and all departments.
- from Student as student, Department as department gives a cartesian product of all students and all departments.
Joins
SQL Joins
Source. Joins used to fetch rows from 2 or more tables based on the relationship between columns in both the tables. Primary key is a column (or a group of columns - composite key) with unique values that identify each row.
- inner join - returns a row when there is a match in both the tables
- left outer join - returns all rows from the left table even if there are no matches on the right table
- right outer join - returns all rows from the right table even if there are no matches on the left table
- full join - returns rows when there is a match in one of the tables
examples:
Employee table:
emp_no | emp_name | dept_no |
1 | xyz | 1 |
2 | abc | 2 |
3 | ghi | 4 |
Department table:
dept_no | dept_name |
1 | IT |
2 | Sales |
3 | Accounts |
inner join:
select emp.emp_no, emp.emp_name, dept.dept_name from employee as emp inner join department as dept on emp.dept_no = dept.dept_no;
emp_no | emp_name | dept_name |
1 | xyz | IT |
2 | abc | Sales |
left outer join
select emp.emp_no, emp.emp_name, dept.dept_name from employee as emp left join department as dept on emp.dept_no = dept.dept_no;
emp_no | emp_name | dept_name |
1 | xyz | IT |
2 | abc | Sales |
3 | ghi |
right outer join
select emp.emp_no, emp.emp_name, dept.dept_name from employee as emp right join department as dept on emp.dept_no = dept.dept_no;
emp_no | emp_name | dept_name |
1 | xyz | IT |
2 | abc | Sales |
Accounts |
full join
select emp.emp_no, emp.emp_name, dept.dept_name from employee as emp full join department as dept on emp.dept_no = dept.dept_no;
emp_no | emp_name | dept_name |
1 | xyz | IT |
2 | abc | Sales |
3 | ghi | |
Accounts |
HQL Joins
Same types of joins as SQL
1. inner join e.g. from Employee as emp inner join | join emp.department as dept
2. left outer join e.g. from Employee as emp left outer join | left join emp.department as dept
3. right outer join e.g. from Employee as emp right outer join | right join emp.department as dept
4. full join
Subscribe to:
Posts (Atom)