ORM – ( Object-relational mapping )
The programmer must either convert the object values into groups of simpler values for storage in the database (and convert them back upon retrieval), or only use simple scalar values within the program. Object-relational mapping is used to implement the first approach.
So basically ORM focuses on the stored procedures because of gaining time and preventing suspicious attack, preventing lack of code and etc. By means of stored procedures developer doesn’t need to touch database directly, that is the main idea.
What about pros and cons ? ORM often reduces the amount of code needed to be written, making the software more robust. There are costs as well as benefits for using O/R mapping. For instance, some O/R mapping tools do not perform well during bulk deletions of data. Stored procedures may have better performance but are not portable(for instance iBatis ,before I talked about iBatis-OR mapping Tool).
An example about mapping;
MyJob.java ;
/**
* Creates an array of <code>IdCode</code> with object type
* <br>According to the lenght of array writes array
* <br><code>IdCodes,Constants.EFFECTIVE</code> values were sent into the <code>MyJobDataObjectDAO</code> and there adds values <code>SubId,effective</code> to the new HashMap
*<br>code>Calculate.listId</code> starts
*<br>So means that this method returns list of distinct division’s first letter. With IdCode parameter. it is enabled to enter more than one Organizations.Therefore it is sat as array of strings.
* For example if given Organizations are IdCode[0] = “TMEMA”; orgCode[1] = “TMMT”; <code>listId()</code> method returns all distinct
* Devision’s first letters like this: V, R, P, K, T, C, N, Z, S, E
*<br>Look up a value in the <code>HashMap </code> and return <code>tranList</code> value for <code>listId</code>
* @param IdCode this parameter takes Organizations name.
* @return list (list of array)
*/ Object [] listId(String [] IdCode);
MyJobImpl.java ;
public Object[] listId(String[] IdCode) {
String IdCodes=”(“;
if (IdCode.length>0){
IdCodes+=”‘” + IdCode[0] + “‘”;
}
for (int i = 1; i < IdCode.length; i++) {
IdCodes+=”,’” + IdCode[i] + “‘”;
}
IdCodes+=”)”;
List list = MyJobDataObjectDAO.listId(IdCodes,Constants.EFFECTIVE); return list.toArray();
}
MyJobObjectDAOImpl.java ;
public List listId(String IdCode,String effective) {
Map map = new HashMap();
map.put(“SubId”,IdCode);
map.put(“effective”,effective);
getSqlMapClientTemplate().queryForList(“Calculate.listId”, map);
List tranList = (List)map.get(“tran”);
return tranList;
}
//Calculate is a stored procedure
MyJobDataObjectDAO.java ;
List listId(String IdCode,String effective);
**Another Important case as well ; as you see , with using Implementation classes , the others don’t know about code that what for it(code) ,except developers.
For more information http://www.agiledata.org/essays/mappingObjects.html serves a great document , I really recommend you to gaze it ; )
Related posts:
- 2Temmuz – Toyota Stajında
- 29Haziran – Toyota Stajında…
- 7 Temmuz StaJ…
- 1Temmuz – Toyota Stajında :)
- 15Haziran – Toyota Stajında İlk Gün
