Mock tests, Interview questions, Tutorials and Tech news
 
 

Archive

Posts Tagged ‘spring’

@Transactional(readOnly=true) in Spring

December 19th, 2010 Vinay 2 comments

@Transactional(readOnly=true) in Spring

What does this mean ?

When a Multi Version Concurrency Control database (Oracle, Postgresql, MySQL + InnoDb) is used, a read only transaction can be translated to the non standard isolation level: READ_ONLY.

The READ_ONLY isolation level provides the same protection as the SERIALIZED isolation level (no dirty reads, no unrepeatable reads, no phantom reads) but doesn’t allow any updates. It also doesn’t cause any lock contention because no locking is required (the database is able to revert back to previous versions of the records ignoring all new changes).

Ms Sql 2005 also has a similar isolation level: SNAPSHOT.

If you specify readOnly as true, the flush mode will be set as FlushMode.NEVER in the current Hibernate Session preventing the session from committing the transaction. Read more…

Configuring datasource in applicationContext.xml through JNDI

December 15th, 2010 Vinay No comments

You can configure JNDI instead of datasource in spring applicationcontext.xml using “org.springframework.jndi.JndiObjectFactoryBean”.

For Example:

<bean id=”dataSource” class=”org.springframework.jndi.JndiObjectFactoryBean”>

<property name=”jndiName”> <

value>java:comp/env/jdbc/appfuse</value>

</property>

</bean>

Categories: Programming / tutorials Tags:

@Autowired does not work in Spring

December 14th, 2010 Vinay No comments

If @Autowired is not working in your spring beans, check your applicationContext.xml file

<?xml version=”1.0″ encoding=”UTF-8″?>
<beans xmlns=”http://www.springframework.org/schema/beans”
xmlns:context=”http://www.springframework.org/schema/context”
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xmlns:aop=”http://www.springframework.org/schema/aop”
xmlns:tx=”http://www.springframework.org/schema/tx”
xmlns:jee=”http://www.springframework.org/schema/jee”
xmlns:util=”http://www.springframework.org/schema/util”
xsi:schemaLocation=”http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans-3.0.xsd

http://www.springframework.org/schema/context

http://www.springframework.org/schema/context/spring-context-3.0.xsd

http://www.springframework.org/schema/tx

http://www.springframework.org/schema/tx/spring-tx-3.0.xsd

http://www.springframework.org/schema/aop

http://www.springframework.org/schema/aop/spring-aop-3.0.xsd

http://www.springframework.org/schema/jee

http://www.springframework.org/schema/jee/spring-jee-3.0.xsd

http://www.springframework.org/schema/util

http://www.springframework.org/schema/util/spring-util-3.0.xsd”>

<bean id=”propertyConfigurerAppContext”>
<property name=”locations”>
<value>classpath:common-configuration.properties</value>
</property>
</bean>
<bean class=”org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor”/>

<!–  support tx annotation –>
<tx:annotation-driven />

</beans>

make sure you have these in your configuration files.

Categories: Programming / tutorials Tags:

How to add SVN plugin for STS ?

October 28th, 2010 Vinay No comments

Spring source comes with default plugin for CVS. They had SVN plugin but it was removed in release 2.3.1 for following reason

We removed the Collabnet SVN from the Extension install for non-Windows platforms as we were seeing lots of issues with the SVN Java native bindings on Linux and Mac.
So if you want to install SVN support please manually install Subclipse or Subversive from their respective update sites.
Currently we can’t provide a solution that works on all platforms due to licensing restrictions on SVNKit. The good news is that we are currently going through the legal process to obtain a SVNKit redistribution license for STS. Once this agreement is in place we can add Subclipse and/or Subversive to the Extension install

Here is how to add the SVN plugin ig you need it

1. Open the STS dashboard.

2. Go to Extensions. This is under help and documentation.

3. Look for Subeclipse. Check the checkbox and click Install.

If you do not see Subeclipse it implies that it is already installed on your IDE.

Core Spring training classes in Burlington, MA

August 11th, 2010 Vinay No comments

If you are new to Spring and would like to learn from experts , there’s a Core Spring class coming
to Burlington, MA on September 7th . This is not cheap. This class costs $2790.

Register Here

After taking this class you will be able to

  • Develop Java applications using the Spring Framework
  • Use Dependency Injection to set up and configure applications
  • Test Spring Applications
  • Use Hibernate and JDBC with Spring to access relation databases
  • Make use of Spring’s support for transactions
  • And much more…

What:          Core Spring Class
Where:        Burlington, MA
When:         September 7-10
Cost:           $2790

Preparing for Spring certification ?

Try out these practice tests

Core Spring Certification practice test 1

Core Spring Certification practice test 2

Prototype scope in Spring beans

July 29th, 2010 Vinay 1 comment

When you specify a bean as prototype in xml file or through annotation

<bean
id=”myBeanInstance”
class=”com.xyx.PrototypeBeanExample”
scope=”prototype”
autowire=”byName”>

</bean>

it means that every time a request for this bean is made, a new instance is created. If you want to see the illustration

Prototype bean in Spring

Prototype is meant for beans which hold some state.

The  bean lifecycle also changes in prototype bean. From Spring’s doc

Spring does not manage the complete lifecycle of a prototype bean: the container instantiates, configures, decorates and otherwise assembles a prototype object, hands it to the client and then has no further knowledge of that prototype instance

Categories: Programming / tutorials Tags: ,

Integrating hibernate search with a Spring and JPA Application

July 19th, 2010 smitha 1 comment

In this post we will talk about how to integrate hibernate Search into your existing Spring, JPA and Hibernate application and some of the challenges we faced.

We  have a web application using Hibernate (with JPA ) and Spring. This application relies on Spring for transaction, bean initialization / injection etc. EntityManager, transaction are configured in application.xml file. When integrating Hibernate search in such an application one might face problems. In this post I am sharing some problems I faced during integration and the solutions for same.

Entitymanager configuration in my application.xml

Spring configuration:
<bean id=”propertyConfigurer”>
<property name=”location” value=”classpath:myproperties.properties”/>
</bean>

Read more…

How good are Spring certification practice tests at Skill-Guru ?

July 7th, 2010 Vinay No comments

In our previous posts we had mentioned that Ikoko has added 2 mock test of 50 questions each at Skill-Guru

Spring certification mock test 1

Spring certification mock test 2

These tests are priced at $0.99 each . So how good are the tests ?

Follow this discussion on javaranch to see what real users who have been through Spring certification are saying about the test

Failed Core Spring certification

Get Adobe Flash playerPlugin by wpburn.com wordpress themes