Posts

Showing posts from March, 2016

Adding "implements serializable" effects - Java

The cost is close to zero, not worth being concerned about. Some further details: There is no increase in the size of each object instance There is a small increase in the size of the class itself, but as this is a one-off cost it is trivial when amortised over a large number of instances There may be a slight additional runtime cost for anything that needs to do interface checks at runtime (reflection, instancof lookups, extra pressure on inline caches etc.). Again, this is likely to be negligible for most purposes. Serializable is a  marker interface , there are no methods that require to be implemented. Other marker interface examples are: Clonable, SingleThreadModel, Event listener. ------------------------------------------------------------------------------------- There is no performance impact unless you perform serialization/deserialization but there are trade offs in terms of api design. From  Effective java  by Joshua Bloch A major cost of...

J2EE Vs Spring

Java EE is an standard, official, specification for a full featured Enterprise Application Framework stack. Includes stuff like Object-Relational Mapping, Security, Web Applications, database connectivity, transactions... On top of Java EE specifications there are JavaEE  implementations/application servers  like: JBoss, Glassfish, WebSphere, Weblogic. Spring on the other hand, is a framework doing lots of the stuff on the Java EE specifications, but in its own form. They don't follow Java EE specifications and APIs for that. But they do include a Web Framework, transaction management, security and several other solutions Java EE offers. ------------------------------------------------------ Java EE: Java EE industry approved standard API based framework IT is predominantly based on annotation and CDI JFC MVC framework for web development JPA implementation to process DB operation JTA API with implementation EJB container and POJO based implementation Ora...

Implicit Cursor vs Explicit Cursor - Oracle DB

A cursor can be explicit or implicit, and either type can be used in a FOR loop.  Why use an explicit cursor FOR loop over an implicit cursor FOR loop? Use an explicit cursor FOR loop when the query will be reused, otherwise an implicit cursor is preferred. Why use a loop with a FETCH rather than a FOR loop that doesn’t have an explicit FETCH? Use a FETCH inside a loop when you need to bulk collect or when you need dynamic SQL. Here is some useful information from the documentation. Example of Implicit Cursor FOR LOOP BEGIN FOR vItems IN ( SELECT last_name FROM employees WHERE manager_id > 120 ORDER BY last_name ) LOOP DBMS_OUTPUT . PUT_LINE ( 'Name = ' || vItems . last_name ); END LOOP ; END ; / Example of Explicit Cursor FOR LOOP DECLARE CURSOR c1 IS SELECT last_name FROM employees WHERE manager_id > 120 ORDER BY last_name ; BEGIN FOR vItems I...

Difference between view and synonym - Oracle DB

View is a virtual table - It can be created on a table or another view. - It is just like a window through which we can access or change base table data. - It does contain data of its own. It always takes data from its base table. - It is stored as a query in data dictionary.Whenever you query a view it gets data from its based table using this query. Main advantage of using views - You can restrict access to predetermined set of rows and columns of a table - You can hide complexity of query  - You can hide complexity of calculation Synonym is alternate name given to table, view, sequence or program unit.  -It is used to mask real name and owner of the object.  - You can provide public access to tables by creating public synonyms.

Synonym - Oracle DB

Image
Overview of Synonyms A  synonym  is an alias for any table, view, materialized view, sequence, procedure, function, package, type, Java class schema object, user-defined object type, or another synonym. Because a synonym is simply an alias, it requires no storage other than its definition in the data dictionary. Synonyms are often used for security and convenience. For example, they can do the following: Mask the name and owner of an object Provide location transparency for remote objects of a distributed database Simplify SQL statements for database users Enable restricted access similar to specialized views when exercising fine-grained access control You can create both public and private synonyms. A  public  synonym is owned by the special user group named  PUBLIC  and every user in a database can access it. A  private  synonym is in the schema of a specific user who has control over its availability to others. Synonyms ...

JavaServer Faces Application - Sample

Creating a Simple JavaServer Faces Application JavaServer Faces technology provides an easy and user-friendly process for creating web applications. Developing a simple JavaServer Faces application typically requires the following tasks: Developing managed beans Creating web pages using component tags Mapping the  javax.faces.webapp.FacesServlet  instance This section describes those tasks through the process of creating a simple JavaServer Faces Facelets application. The example is a Hello application that includes a managed bean and a web page. When accessed by a client, the web page prints out a  Hello World  message. The tasks involved in developing this application can be examined by looking at the application components in detail. Developing the Managed Bean A managed bean is a lightweight container-managed object. Components in a page are associated with managed beans that provide application logic. The example managed bean,   Hello.jav...