<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=martypitt" rel="nofollow">Marty Pitt</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-9741?redirect=false" rel="nofollow">SPR-9741</a></strong> and commented</p>
<p dir="auto">When specifying the name of a persistence unit to use for LocalContainerEntityManagerFactoryBean (ie., assuming there are multiple persistence units defined in persistence.xml), this name is now applied to the persistence unit from scanned pacakges.</p>
<p dir="auto">In 3.1.0, the name applied to the generated package was 'default'.  However, now, the name applied is the one defined in the entityManager configuration.</p>
<p dir="auto">This results in an exception "Conflicting persistence unit definitions for name 'xxx'".</p>
<p dir="auto">This is a breaking change in behaviour from 3.1.0 to 3.1.2.</p>
<p dir="auto">The change is caused by new setter behaviour introduced in LocalContainerEntityManagerFactoryBean in 3.1.2, specifically this code:</p>
<p dir="auto">{{<br>
<code class="notranslate">@Override</code><br>
public void setPersistenceUnitName(String persistenceUnitName) {<br>
super.setPersistenceUnitName(persistenceUnitName);<br>
this.internalPersistenceUnitManager.setDefaultPersistenceUnitName(persistenceUnitName);<br>
}<br>
}}</p>
<p dir="auto">This changes the internal defaultPersistenceUnitName from <code class="notranslate">default</code>.  Later, when <code class="notranslate">DefaultPersistenceUnit.buildDefaultPersistenceUnitInfo()</code> is called, a new persistence unit is generated using this name:</p>
<p dir="auto">{{<br>
private SpringPersistenceUnitInfo buildDefaultPersistenceUnitInfo() {<br>
SpringPersistenceUnitInfo scannedUnit = new SpringPersistenceUnitInfo();<br>
scannedUnit.setPersistenceUnitName(this.defaultPersistenceUnitName);<br>
scannedUnit.setExcludeUnlistedClasses(true);<br>
}}</p>
<p dir="auto">This then results in an exception being thrown.</p>
<p dir="auto">As an example, here's the defined <code class="notranslate">Persistence.xml</code>, which contains both a prod config, and a test config:</p>
<p dir="auto">{{</p>
<p dir="auto">&lt;?xml version="1.0" encoding="UTF-8"?&gt;</p>
<p dir="auto">&lt;persistence version="1.0"<br>
xmlns="<a href="http://java.sun.com/xml/ns/persistence" rel="nofollow">http://java.sun.com/xml/ns/persistence</a>" xmlns:xsi="<a href="http://www.w3.org/2001/XMLSchema-instance" rel="nofollow">http://www.w3.org/2001/XMLSchema-instance</a>"<br>
xsi:schemaLocation="<a href="http://java.sun.com/xml/ns/persistence" rel="nofollow">http://java.sun.com/xml/ns/persistence</a> <a href="http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd%22%3E" rel="nofollow">http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"&gt;</a><br>
&lt;persistence-unit name="production"&gt;<br>
&lt;properties&gt;</p>
<p dir="auto">&lt;!-- JPA Configuration goes here --&gt;<br>
&lt;/properties&gt;<br>
&lt;/persistence-unit&gt;<br>
&lt;persistence-unit name="test" transaction-type="RESOURCE_LOCAL"&gt;<br>
&lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt;<br>
&lt;properties&gt;<br>
&lt;!-- JPA Configuration goes here --&gt;<br>
&lt;/properties&gt;<br>
&lt;/persistence-unit&gt;<br>
&lt;/persistence&gt;<br>
}}</p>
<p dir="auto">Then, the appropriate config is selected in the EntityManager configration:</p>
<p dir="auto">{{<br>
&lt;bean id="entityManagerFactory"<br>
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt;<br>
&lt;property name="dataSource" ref="dataSource" /&gt;<br>
&lt;property name="packagesToScan"&gt;<br>
&lt;list&gt;<br>
&lt;value&gt;aa.bb.cc&lt;/value&gt;<br>
&lt;/list&gt;<br>
&lt;/property&gt;<br>
&lt;property name="persistenceUnitName" value="test" /&gt;<br>
&lt;property name="jpaVendorAdapter"&gt;<br>
&lt;bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"&gt;<br>
&lt;property name="showSql" value="true" /&gt;<br>
&lt;property name="generateDdl" value="true" /&gt;<br>
&lt;property name="databasePlatform" value="org.hibernate.dialect.H2Dialect" /&gt;<br>
&lt;/bean&gt;<br>
&lt;/property&gt;<br>
&lt;/bean&gt;<br>
}}</p>
<p dir="auto">This causes the exception.</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 3.1.2</p>
<p dir="auto"><strong>Reference URL:</strong> <a href="http://stackoverflow.com/questions/12189921/conflicting-persistence-unit-definitions-when-testing" rel="nofollow">http://stackoverflow.com/questions/12189921/conflicting-persistence-unit-definitions-when-testing</a></p>
<p dir="auto"><strong>Referenced from:</strong> commits <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/spring-projects/spring-framework/commit/0cf4a2626bae8707a324aef1f0e62b06a80c2ab8/hovercard" href="https://github.com/spring-projects/spring-framework/commit/0cf4a2626bae8707a324aef1f0e62b06a80c2ab8"><tt>0cf4a26</tt></a>, <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/spring-projects/spring-framework/commit/f32e4077fae1ce986ca565c73b1703f74dd6ba31/hovercard" href="https://github.com/spring-projects/spring-framework/commit/f32e4077fae1ce986ca565c73b1703f74dd6ba31"><tt>f32e407</tt></a></p>
<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=snowway" rel="nofollow">薛伟</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-1003?redirect=false" rel="nofollow">SPR-1003</a></strong> and commented</p>
<p dir="auto">A FactoryBean which can use the powerful OGNL expression language<br>
with OGNL support,developers can invoke method,static method,static field and some advanced operation straightforward and easy.</p>
<p dir="auto">the sourcecode<br>
/*</p>
<ul dir="auto">
<li>Created on 2005-6-2<br>
*/<br>
package org.snowway.spring.extension;</li>
</ul>
<p dir="auto">import java.util.Collections;<br>
import java.util.Hashtable;<br>
import java.util.Map;</p>
<p dir="auto">import org.springframework.beans.BeansException;<br>
import org.springframework.beans.FatalBeanException;<br>
import org.springframework.beans.factory.FactoryBean;<br>
import org.springframework.context.ApplicationContext;<br>
import org.springframework.context.ApplicationContextAware;</p>
<p dir="auto">import ognl.Ognl;<br>
import ognl.OgnlException;<br>
/**</p>
<ul dir="auto">
<li>
<p dir="auto"><code class="notranslate">@author</code> snowway</p>
</li>
<li>
<p dir="auto"><code class="notranslate">@version</code> <math-renderer class="js-inline-math" style="display: inline" data-static-url="https://github.githubassets.com/static" data-run-id="4a35e0e54f320d0ab16695e3d22b9cee">$Id$</math-renderer></p>
</li>
<li>
</li></ul>
<p dir="auto">&lt;p&gt;</p>
<ul dir="auto">
<li>
<p dir="auto">A FactoryBean which can use the powerful OGNL expression language&lt;br&gt;</p>
</li>
<li>
<p dir="auto">need runtime OGNL support(e.g. ognl-2.6.5.jar)&lt;br&gt;</p>
</li>
<li>
</li><li>
<p dir="auto">the default root object for OGNL expression is ApplicationContext instance&lt;br&gt;<br>
*/<br>
public class OgnlExpressionFactoryBean implements FactoryBean,ApplicationContextAware{</p>
<p dir="auto">//the ognl expression<br>
private String expression;</p>
<p dir="auto">//the naming context for the evaluation<br>
private Map context;</p>
<p dir="auto">private ApplicationContext applicationContext;</p>
<p dir="auto">//the ognl root object,default is ApplicationContext instance<br>
private Object root;</p>
<p dir="auto">//is user define custom root object<br>
private boolean _hasSetRootExplicit = false;</p>
<p dir="auto">/* (non-Javadoc)</p>
<ul dir="auto">
<li>
<p dir="auto"><code class="notranslate">@see</code> org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext)<br>
*/<br>
public void setApplicationContext(ApplicationContext applicationContext)<br>
throws BeansException {</p>
<p dir="auto">this.applicationContext = applicationContext;<br>
//when no custom root object,use ApplicationContext default<br>
if(!_hasSetRootExplicit)<br>
this.root = this.applicationContext;<br>
}</p>
</li>
</ul>
<p dir="auto">/**</p>
<ul dir="auto">
<li>
<code class="notranslate">@param</code> expression the ognl expression to set.<br>
*/<br>
public void setExpression(String expression) {<br>
this.expression = expression;<br>
}</li>
</ul>
<p dir="auto">/**</p>
<ul dir="auto">
<li>
<code class="notranslate">@param</code> context the naming context for the evaluation<br>
*/<br>
public void setContext(Map context) {<br>
this.context = context;<br>
}</li>
</ul>
<p dir="auto">/**</p>
<ul dir="auto">
<li>
<code class="notranslate">@param</code> root the root object for the OGNL expression<br>
*/<br>
public void setRoot(Object root) {<br>
_hasSetRootExplicit = true;<br>
this.root = root;<br>
}</li>
</ul>
<p dir="auto">public Object getObject() throws Exception {<br>
if(expression==null)<br>
throw new IllegalArgumentException("ognl expression cannot be null!");</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content=" //the return object after ognl evaluation
 Object returnObject = null;
 try{
 	returnObject = OgnlExpressionEvaluator.evaluate(expression, context, root);
 }catch(OgnlException ex){
 	//a better way is throw appropriate Exception insteadof RuntimeException
 	//I write RuntimeException for the sake of simplicity
 	throw new RuntimeException(&quot;error in evaluation &quot;,ex);
 }

 if(returnObject==null)
 	throw new FatalBeanException(&quot;OgnlExpressionFactoryBean is not allowed to return null, &quot; +
 		    &quot;but the expression '&quot; + this.expression + &quot;' return null&quot;);

 return returnObject;"><pre class="notranslate"><code class="notranslate"> //the return object after ognl evaluation
 Object returnObject = null;
 try{
 	returnObject = OgnlExpressionEvaluator.evaluate(expression, context, root);
 }catch(OgnlException ex){
 	//a better way is throw appropriate Exception insteadof RuntimeException
 	//I write RuntimeException for the sake of simplicity
 	throw new RuntimeException("error in evaluation ",ex);
 }

 if(returnObject==null)
 	throw new FatalBeanException("OgnlExpressionFactoryBean is not allowed to return null, " +
 		    "but the expression '" + this.expression + "' return null");

 return returnObject;
</code></pre></div>
<p dir="auto">}<br>
/**</p>
<ul dir="auto">
<li>unknown type<br>
*/<br>
public Class getObjectType() {<br>
return null;<br>
}</li>
</ul>
<p dir="auto">public boolean isSingleton() {<br>
return true;<br>
}</p>
<p dir="auto">/**</p>
<ul dir="auto">
<li>
<p dir="auto"><code class="notranslate">@author</code> snowway</p>
</li>
<li>
<p dir="auto"><code class="notranslate">@version</code> <math-renderer class="js-inline-math" style="display: inline" data-static-url="https://github.githubassets.com/static" data-run-id="4a35e0e54f320d0ab16695e3d22b9cee">$Id$</math-renderer></p>
</li>
<li>
</li></ul>
<p dir="auto">&lt;p&gt;</p>
<ul dir="auto">
<li>
<p dir="auto">a helper class for evaluate ognl expression and cache the compiled expression object<br>
*/<br>
private static class OgnlExpressionEvaluator{</p>
<p dir="auto">//a map for pre-compiled ognl expression object<br>
private static Map expressions = new Hashtable();</p>
<p dir="auto">/**</p>
<ul dir="auto">
<li>
<p dir="auto"><code class="notranslate">@param</code> expression the OGNL expression</p>
</li>
<li>
<p dir="auto"><code class="notranslate">@param</code> context the naming context for the evaluation</p>
</li>
<li>
<p dir="auto"><code class="notranslate">@param</code> root the root object for the OGNL expression<br>
*/<br>
public static Object evaluate(String expression,<br>
Map context,Object root) throws OgnlException{</p>
<p dir="auto">//the context can not be null,otherwise OGNL will throw NullPointerException<br>
if(context == null)<br>
context = Collections.EMPTY_MAP;</p>
<p dir="auto">//try to retrieve pre-compiled ognl expression object<br>
Object compiledObject = expressions.get(expression);</p>
<p dir="auto">//compile first if failed to retrieve pre-compiled object<br>
if(compiledObject==null){<br>
expressions.put(expression,compiledObject = Ognl.parseExpression(expression));<br>
}</p>
<p dir="auto">//evaluate<br>
return Ognl.getValue(compiledObject,context,root);<br>
}<br>
}<br>
}</p>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<p dir="auto">the demo xml</p>
<p dir="auto">&lt;?xml version="1.0" encoding="UTF-8"?&gt;<br>
&lt;!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"<br>
"<a href="http://www.springframework.org/dtd/spring-beans.dtd%22%3E" rel="nofollow">http://www.springframework.org/dtd/spring-beans.dtd"&gt;</a><br>
&lt;beans&gt;<br>
&lt;!--<br>
static method invocation<br>
it will return java system properties<br>
@ represent static method or field invocation<br>
--&gt;<br>
&lt;bean id="sysprops" class="org.snowway.spring.extension.OgnlExpressionFactoryBean"&gt;<br>
&lt;property name="expression"&gt;<br>
&lt;value&gt;<br>
<code class="notranslate">@java</code>.lang.System@getProperties()<br>
&lt;/value&gt;<br>
&lt;/property&gt;<br>
&lt;/bean&gt;</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&lt;!--
	static filed reference
	it will return java.io.PrintStream object
	@ represent static method or field invocation
--&gt;
&lt;bean id=&quot;printStream&quot; class=&quot;org.snowway.spring.extension.OgnlExpressionFactoryBean&quot;&gt;
	&lt;property name=&quot;expression&quot;&gt;
		&lt;value&gt;@java.lang.System@out&lt;/value&gt;
	&lt;/property&gt;
&lt;/bean&gt;

&lt;!--
	method invocation return value
	it will return &quot;ABCDE&quot;
--&gt;
&lt;bean id=&quot;uppercaseString&quot; class=&quot;org.snowway.spring.extension.OgnlExpressionFactoryBean&quot;&gt;
	&lt;property name=&quot;expression&quot;&gt;
		&lt;value&gt;&quot;abcde&quot;.toUpperCase()&lt;/value&gt;
	&lt;/property&gt;
&lt;/bean&gt;

&lt;!--
	use existing bean as the root of OGNL expression
	it will return java.version system property value (e.g. 1.4.2_05)
	the root object is java.util.Properties,so you can invoke java.util.Properties.getProperty method
	it can alse write as #this.getProperty(&quot;java.version&quot;),#this represent the root now
--&gt;
&lt;bean id=&quot;javaVersion&quot; class=&quot;org.snowway.spring.extension.OgnlExpressionFactoryBean&quot;&gt;
	&lt;property name=&quot;expression&quot;&gt;
		&lt;value&gt;
			getProperty(&quot;java.version&quot;)
		&lt;/value&gt;
	&lt;/property&gt;
	&lt;property name=&quot;root&quot;&gt;
		&lt;ref local=&quot;sysprops&quot;/&gt;
	&lt;/property&gt;
&lt;/bean&gt;

&lt;!--
	use naming context in OGNL evaluation
	it will return such as &quot;1.4.2_05 ABCDE&quot;
	when you need more object for evaluation,you can put object to naming context.
	you can use #mapkey for object in naming contenxt
--&gt;
&lt;bean id=&quot;javaVersionAndUppercaseString&quot;
	class=&quot;org.snowway.spring.extension.OgnlExpressionFactoryBean&quot;&gt;
	&lt;property name=&quot;expression&quot;&gt;
		&lt;value&gt;
			#sysprops.getProperty(&quot;java.version&quot;) + &quot; &quot; +#uppercaseString
		&lt;/value&gt;
	&lt;/property&gt;
	&lt;property name=&quot;context&quot;&gt;
		&lt;map&gt;
			&lt;entry key=&quot;sysprops&quot;&gt;
				&lt;ref local=&quot;sysprops&quot;/&gt;
			&lt;/entry&gt;
			&lt;entry key=&quot;uppercaseString&quot;&gt;
				&lt;ref local=&quot;uppercaseString&quot;/&gt;
			&lt;/entry&gt;
		&lt;/map&gt;
	&lt;/property&gt;
&lt;/bean&gt;


&lt;!--
	ApplicationContext bean reference
	it will return user property(a list of Map.Entry item)
	i use ApplicationContext object as OGNL root object for convenience.
	getBean is the method of ApplicationContext
--&gt;
&lt;bean id=&quot;userprops&quot; class=&quot;org.snowway.spring.extension.OgnlExpressionFactoryBean&quot;&gt;
	&lt;property name=&quot;expression&quot;&gt;
		&lt;value&gt;
			&lt;!--
				collection selection
				the syntax is collection.{? expression_return_true_or_false }
				in the {},#this is current item in collection,not the root object of OGNL
				when expression_return_true_or_false evaluate to true,the current item is reserved
				e.g. listeners.{? #this instanceof java.awt.event.ActionListener}
			--&gt;
			getBean(&quot;sysprops&quot;).entrySet().{? #this.key.startsWith(&quot;user&quot;)}
		&lt;/value&gt;
	&lt;/property&gt;
&lt;/bean&gt;

&lt;!--
	collection projection
	it will return [2,3,4]
--&gt;
&lt;bean id=&quot;addOneForEachElement&quot; class=&quot;org.snowway.spring.extension.OgnlExpressionFactoryBean&quot;&gt;
	&lt;property name=&quot;expression&quot;&gt;
		&lt;value&gt;
			&lt;!--
				collection projection
				the syntax is collection.{ expression }
				in the {},#this is current item in collection,not the root object for OGNL
				collection projection expression will iterate all item,and each item will pass
				into expression and return the expression value

				use the #var=expression syntax to define a variable.
				one more thing,OGNL use , to separate expressions, and the entire expression result
				is the last one
			--&gt;
			&lt;![CDATA[
				#list = new java.util.ArrayList(),
				#list.add(1),#list.add(2),#list.add(3),
				#list.{ #this + 1 }
				]]&gt;
		&lt;/value&gt;
	&lt;/property&gt;
&lt;/bean&gt;

&lt;!--
	object navigation
	it will return &quot;my name is:snowway and my birthday is:Tue Sep 18 00:00:00 CST 1979 &quot;
--&gt;
&lt;bean id=&quot;objectNavigation&quot; class=&quot;org.snowway.spring.extension.OgnlExpressionFactoryBean&quot;&gt;
	&lt;property name=&quot;expression&quot;&gt;
		&lt;value&gt;
			&lt;!--
				use #{key1:value1,key2:value2} to define a map
				use #@java.util.LinkedHashMap@{key1:value1,key2:value2}	to define specified map
				map.key == map[key]
			--&gt;
			&lt;![CDATA[
				#map = #@java.util.LinkedHashMap@{&quot;name&quot;:&quot;snowway&quot;,
					    &quot;age&quot;:26,
					    &quot;email&quot;:&quot;snowway.xue@gmail.com&quot;,
						&quot;birthday&quot;:new java.util.GregorianCalendar(1979,8,18)},
				&quot;my name is:&quot;+#map['name']+&quot; and my birthday is:&quot;+#map.birthday.time
				]]&gt;
		&lt;/value&gt;
	&lt;/property&gt;
&lt;/bean&gt;
&lt;!--
	please read OGNL LanguageGuide(www.ognl.org) for other expression usage
--&gt;"><pre class="notranslate"><code class="notranslate">&lt;!--
	static filed reference
	it will return java.io.PrintStream object
	@ represent static method or field invocation
--&gt;
&lt;bean id="printStream" class="org.snowway.spring.extension.OgnlExpressionFactoryBean"&gt;
	&lt;property name="expression"&gt;
		&lt;value&gt;@java.lang.System@out&lt;/value&gt;
	&lt;/property&gt;
&lt;/bean&gt;

&lt;!--
	method invocation return value
	it will return "ABCDE"
--&gt;
&lt;bean id="uppercaseString" class="org.snowway.spring.extension.OgnlExpressionFactoryBean"&gt;
	&lt;property name="expression"&gt;
		&lt;value&gt;"abcde".toUpperCase()&lt;/value&gt;
	&lt;/property&gt;
&lt;/bean&gt;

&lt;!--
	use existing bean as the root of OGNL expression
	it will return java.version system property value (e.g. 1.4.2_05)
	the root object is java.util.Properties,so you can invoke java.util.Properties.getProperty method
	it can alse write as #this.getProperty("java.version"),#this represent the root now
--&gt;
&lt;bean id="javaVersion" class="org.snowway.spring.extension.OgnlExpressionFactoryBean"&gt;
	&lt;property name="expression"&gt;
		&lt;value&gt;
			getProperty("java.version")
		&lt;/value&gt;
	&lt;/property&gt;
	&lt;property name="root"&gt;
		&lt;ref local="sysprops"/&gt;
	&lt;/property&gt;
&lt;/bean&gt;

&lt;!--
	use naming context in OGNL evaluation
	it will return such as "1.4.2_05 ABCDE"
	when you need more object for evaluation,you can put object to naming context.
	you can use #mapkey for object in naming contenxt
--&gt;
&lt;bean id="javaVersionAndUppercaseString"
	class="org.snowway.spring.extension.OgnlExpressionFactoryBean"&gt;
	&lt;property name="expression"&gt;
		&lt;value&gt;
			#sysprops.getProperty("java.version") + " " +#uppercaseString
		&lt;/value&gt;
	&lt;/property&gt;
	&lt;property name="context"&gt;
		&lt;map&gt;
			&lt;entry key="sysprops"&gt;
				&lt;ref local="sysprops"/&gt;
			&lt;/entry&gt;
			&lt;entry key="uppercaseString"&gt;
				&lt;ref local="uppercaseString"/&gt;
			&lt;/entry&gt;
		&lt;/map&gt;
	&lt;/property&gt;
&lt;/bean&gt;


&lt;!--
	ApplicationContext bean reference
	it will return user property(a list of Map.Entry item)
	i use ApplicationContext object as OGNL root object for convenience.
	getBean is the method of ApplicationContext
--&gt;
&lt;bean id="userprops" class="org.snowway.spring.extension.OgnlExpressionFactoryBean"&gt;
	&lt;property name="expression"&gt;
		&lt;value&gt;
			&lt;!--
				collection selection
				the syntax is collection.{? expression_return_true_or_false }
				in the {},#this is current item in collection,not the root object of OGNL
				when expression_return_true_or_false evaluate to true,the current item is reserved
				e.g. listeners.{? #this instanceof java.awt.event.ActionListener}
			--&gt;
			getBean("sysprops").entrySet().{? #this.key.startsWith("user")}
		&lt;/value&gt;
	&lt;/property&gt;
&lt;/bean&gt;

&lt;!--
	collection projection
	it will return [2,3,4]
--&gt;
&lt;bean id="addOneForEachElement" class="org.snowway.spring.extension.OgnlExpressionFactoryBean"&gt;
	&lt;property name="expression"&gt;
		&lt;value&gt;
			&lt;!--
				collection projection
				the syntax is collection.{ expression }
				in the {},#this is current item in collection,not the root object for OGNL
				collection projection expression will iterate all item,and each item will pass
				into expression and return the expression value

				use the #var=expression syntax to define a variable.
				one more thing,OGNL use , to separate expressions, and the entire expression result
				is the last one
			--&gt;
			&lt;![CDATA[
				#list = new java.util.ArrayList(),
				#list.add(1),#list.add(2),#list.add(3),
				#list.{ #this + 1 }
				]]&gt;
		&lt;/value&gt;
	&lt;/property&gt;
&lt;/bean&gt;

&lt;!--
	object navigation
	it will return "my name is:snowway and my birthday is:Tue Sep 18 00:00:00 CST 1979 "
--&gt;
&lt;bean id="objectNavigation" class="org.snowway.spring.extension.OgnlExpressionFactoryBean"&gt;
	&lt;property name="expression"&gt;
		&lt;value&gt;
			&lt;!--
				use #{key1:value1,key2:value2} to define a map
				use #@java.util.LinkedHashMap@{key1:value1,key2:value2}	to define specified map
				map.key == map[key]
			--&gt;
			&lt;![CDATA[
				#map = #@java.util.LinkedHashMap@{"name":"snowway",
					    "age":26,
					    "email":"snowway.xue@gmail.com",
						"birthday":new java.util.GregorianCalendar(1979,8,18)},
				"my name is:"+#map['name']+" and my birthday is:"+#map.birthday.time
				]]&gt;
		&lt;/value&gt;
	&lt;/property&gt;
&lt;/bean&gt;
&lt;!--
	please read OGNL LanguageGuide(www.ognl.org) for other expression usage
--&gt;
</code></pre></div>
<p dir="auto">&lt;/beans&gt;</p>
<hr>
<p dir="auto"><strong>Attachments:</strong></p>
<ul dir="auto">
<li><a href="https://jira.spring.io/secure/attachment/10761/ognl-2.6.5.jar" rel="nofollow">ognl-2.6.5.jar</a> (<em>163.99 kB</em>)</li>
<li><a href="https://jira.spring.io/secure/attachment/10760/OgnlExpressionFactoryBean.rar" rel="nofollow">OgnlExpressionFactoryBean.rar</a> (<em>3.20 kB</em>)</li>
</ul>
<p dir="auto"><strong>Issue Links:</strong></p>
<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398048048" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/4739" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/4739/hovercard" href="https://github.com/spring-projects/spring-framework/issues/4739">#4739</a> Introducing Expression Language Support (<em><strong>"duplicates"</strong></em>)</li>
</ul>