<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.infinite-erp.co.id/index.php?action=history&amp;feed=atom&amp;title=Common_Issues_Tips_and_Tricks</id>
	<title>Common Issues Tips and Tricks - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.infinite-erp.co.id/index.php?action=history&amp;feed=atom&amp;title=Common_Issues_Tips_and_Tricks"/>
	<link rel="alternate" type="text/html" href="https://wiki.infinite-erp.co.id/index.php?title=Common_Issues_Tips_and_Tricks&amp;action=history"/>
	<updated>2026-04-06T13:12:47Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.31.1</generator>
	<entry>
		<id>https://wiki.infinite-erp.co.id/index.php?title=Common_Issues_Tips_and_Tricks&amp;diff=276&amp;oldid=prev</id>
		<title>Wikiadmin: Created page with &quot;== Common Issues, Tips and Tricks ==  This part of the developers guide is dedicated to discussing common issues and answering frequently asked questions. It tries to provide...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.infinite-erp.co.id/index.php?title=Common_Issues_Tips_and_Tricks&amp;diff=276&amp;oldid=prev"/>
		<updated>2018-10-15T13:52:05Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;== Common Issues, Tips and Tricks ==  This part of the developers guide is dedicated to discussing common issues and answering frequently asked questions. It tries to provide...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Common Issues, Tips and Tricks ==&lt;br /&gt;
&lt;br /&gt;
This part of the developers guide is dedicated to discussing common issues and answering frequently asked questions. It tries to provide tips and tricks for common obstacles encountered when developing and extending Openbravo.&lt;br /&gt;
&lt;br /&gt;
== Java Development Issues, Build Path problems ==&lt;br /&gt;
&lt;br /&gt;
To check for a cause and solution check the [[Installation_and_setup_of_Eclipse_IDE|Setup for Eclipse guide]] and specifically the section on [[Installation_and_setup_of_Eclipse_IDE#Build_Path_Problems:_Common_Causes_and_Solutions|Build Path]] problems.&lt;br /&gt;
&lt;br /&gt;
== Client side coding, JavaScript ==&lt;br /&gt;
&lt;br /&gt;
This section highlights specific topics related to client side coding in JavaScript.&lt;br /&gt;
&lt;br /&gt;
=== javascript error on OB object: OB undefined ===&lt;br /&gt;
This can happen if the javascript you created is loaded before the general Openbravo javascript code. To repair this you have to make sure that your module depends on the User Interface Application module. Based on this the Openbravo system will load your javascript after the base javascript provided by Openbravo.&lt;br /&gt;
&lt;br /&gt;
In general if your module depends on javascript provided by other modules, you should set the correct dependency in the module dependencies.&lt;br /&gt;
&lt;br /&gt;
See [[How_To_Create_and_Package_a_Module#Creating_a_Module|here]] for more information.&lt;br /&gt;
&lt;br /&gt;
=== Use jslint ===&lt;br /&gt;
When you do your own client side javascript coding it can help to let your code be automatically checked using [http://www.jslint.com/ jslint]. At Openbravo we run jslint for all the javascript code being committed to the repository. We use [http://code.google.com/p/jslint4java/ JSLint4Java] for this, we enable the automatic check by adding this to the hgrc file in the .hg directory:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;ini&amp;quot;&amp;gt;&lt;br /&gt;
[hooks]&lt;br /&gt;
precommit = modules/org.openbravo.client.kernel/jslint/jscheck-hg&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you work in a custom module then from MP31, there is another script which you should use, add a hook like this in the hgrc file in the .hg directory in your module:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;ini&amp;quot;&amp;gt;&lt;br /&gt;
[hooks]&lt;br /&gt;
pretxncommit = ../org.openbravo.client.kernel/jslint/jscheck-module-hg&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Read this book: JavaScript The Good Parts ===&lt;br /&gt;
JavaScript is not Java. '''To really understand JavaScript it is  crucial to read this book''': [http://oreilly.com/catalog/9780596517748 JavaScript The Good Parts].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:js_goodparts.gif|center]]&lt;br /&gt;
&lt;br /&gt;
=== Debugging JavaScript ===&lt;br /&gt;
All the static JavaScript code (from all modules) is concatenated into one large JavaScript file which is stored in the web application directory (in web/js/gen). The name of the file is based on a hash of the content (see the image below). You can check out the contents of the file using the browsers debugger. From there you can debug your code. At Openbravo we use Chromium and its [http://code.google.com/chrome/devtools/docs/scripts.html debugger] most of the time.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:chrome_debugger.png|center|700px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When working with client side code it is important to learn how to use the Chromium or Firefox debugger and console. Also check out the network tabs of the debugging tools to analyze the requests being done by the system. Search the internet for more information.&lt;br /&gt;
&lt;br /&gt;
'''To see non-minimized code in the debugger you need to have the core/kernel/application modules in development.'''&lt;br /&gt;
&lt;br /&gt;
=== JavaScript Coding Conventions ===&lt;br /&gt;
Check out the [[JavaScript_Coding_Conventions]] for specific tips on coding in JavaScript.&lt;br /&gt;
&lt;br /&gt;
=== Client side API ===&lt;br /&gt;
Openbravo provides and implements several client side components for sending requests to the server, internationalization etc. See the [[Client_Side_Javascript_API|Client Side JavaScript API]] for more information. &lt;br /&gt;
&lt;br /&gt;
=== Smartclient ===&lt;br /&gt;
Openbravo uses the [http://www.smartclient.com Smartclient] client side user interface library for implementing components. To work and development in Openbravo and create new widgets you need to understand Smartclient. Check out these resources:&lt;br /&gt;
* [http://www.smartclient.com/index.jsp#_Welcome Smartclient demo]&lt;br /&gt;
* [http://forums.smartclient.com/ Smartclient forum]&lt;br /&gt;
* [http://www.smartclient.com/docs/8.0/a/b/c/go.html Smartclient reference]&lt;br /&gt;
&lt;br /&gt;
It can help to have the Smartclient source code and reference material in your Eclipse workspace, it is very easy to search source code then. The latest Smartclient source code is available in this Mercurial repository:&lt;br /&gt;
https://code.openbravo.com/erp/mods/org.openbravo.userinterface.smartclient.dev/&lt;br /&gt;
&lt;br /&gt;
=== Videos ===&lt;br /&gt;
Here you have a list of 3 sessions of ''&amp;quot;Introduction to JavaScript&amp;quot;'', the sessions were held on Nov. 26th, 30th and Dec 1st 2010.&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;width:100%;background:#ffffcc&amp;quot;&lt;br /&gt;
|- style=&amp;quot;text-align:center;width:100%&amp;quot; &lt;br /&gt;
| [[Image:Warning.png]] The sessions recorded and listed here are in '''''Spanish'''''&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Session 1: Introduction to JavaScript ====&lt;br /&gt;
* Part 1: [http://openbravo.emea.acrobat.com/p58999753/ http://openbravo.emea.acrobat.com/p58999753/]&lt;br /&gt;
* Part 2: [http://openbravo.emea.acrobat.com/p79534671/ http://openbravo.emea.acrobat.com/p58999753/]&lt;br /&gt;
&lt;br /&gt;
==== Session 2: Introduction to SmartClient ====&lt;br /&gt;
* Part 1: [http://openbravo.emea.acrobat.com/p84569149/ http://openbravo.emea.acrobat.com/p84569149/]&lt;br /&gt;
&lt;br /&gt;
==== Session 3: Introduction to New Architecture ====&lt;br /&gt;
* Part 1: [http://openbravo.emea.acrobat.com/p14323450/ http://openbravo.emea.acrobat.com/p14323450/]&lt;br /&gt;
&lt;br /&gt;
=== Resources ===&lt;br /&gt;
&lt;br /&gt;
* JavaScript: The Good Parts [http://oreilly.com/catalog/9780596517748/ http://oreilly.com/catalog/9780596517748/]&lt;br /&gt;
* JavaScript: The Good Parts (video) [http://video.yahoo.com/video/play?vid=630959 http://video.yahoo.com/video/play?vid=630959]&lt;br /&gt;
* Douglas Crockford — The JavaScript Programming Language [http://developer.yahoo.com/yui/theater/ http://developer.yahoo.com/yui/theater/]&lt;br /&gt;
* JavaScript in Ten (arbitrarily long) Minutes  [https://github.com/spencertipping/js-in-ten-minutes https://github.com/spencertipping/js-in-ten-minutes]&lt;br /&gt;
* Slides sources (Markdown) used with [https://github.com/schacon/showoff showoff] [http://bitbucket.org/iperdomo/js-training/get/tip.zip http://bitbucket.org/iperdomo/js-training/get/tip.zip]&lt;br /&gt;
* A nice tutorial on closures and function scoping: [http://nathansjslessons.appspot.com/ [http://nathansjslessons.appspot.com/]&lt;br /&gt;
&lt;br /&gt;
== Weld ==&lt;br /&gt;
&lt;br /&gt;
=== My component is not found ===&lt;br /&gt;
If your component is not found maybe it falls within the exclusion filter defined in the Weld module. See [[Openbravo_3_Architecture#Analyzing_the_classpath|here]] for more information.&lt;br /&gt;
&lt;br /&gt;
=== Can I run logic when the application starts? ===&lt;br /&gt;
&lt;br /&gt;
Yes you can see [[Openbravo_3_Architecture#Implement_Application_Initialization_Logic|here]] for more information.&lt;br /&gt;
&lt;br /&gt;
== Data Access Layer ==&lt;br /&gt;
&lt;br /&gt;
=== SQL Functions in HQL: no data type for node error === &lt;br /&gt;
&lt;br /&gt;
See this [[Data_Access_Layer#SQL_Functions_in_HQL|wiki page]] for information on how to use SQL functions in HQL.&lt;br /&gt;
&lt;br /&gt;
=== Getting warning: Unbalanced calls to enableAsAdminContext and resetAsAdminContext ===&lt;br /&gt;
&lt;br /&gt;
This warning is displayed (together with a stacktrace) when setting administrator mode is not done correctly. See [[Data_Access_Layer#Administrator_Mode|this part]] of the developers guide.&lt;br /&gt;
&lt;br /&gt;
=== How to call a Stored Procedure/Process through the DAL ===&lt;br /&gt;
See these [[How_to_call_a_stored_procedure_from_the_DAL#Notes|notes]] in the howto on calling a process through the DAL.&lt;br /&gt;
&lt;br /&gt;
=== How to read data visible only from a specific Organization ===&lt;br /&gt;
The default DAL behavior (of OBQuery and OBCriteria) is to read information from all readable organizations. This is all organizations to which the current role has access. However, sometimes you want to read information which is only accessible/visible from a specific organization. The code snippet below shows how this can be accomplished:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;final OBCriteria&amp;lt;PaymentTerm&amp;gt; obc = OBDal.getInstance().createCriteria(PaymentTerm.class);&lt;br /&gt;
obc.add(Expression.in(&amp;quot;organization.id&amp;quot;, OBContext.getOBContext().getOrganizationStructureProvider().getNaturalTree(orgId)));&lt;br /&gt;
obc.setFilterOnReadableOrganization(false);&lt;br /&gt;
final List&amp;lt;PaymentTerm&amp;gt; pts = obc.list();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This code snippet shows that you have to add an in expression to the OBCriteria and then disable the standard organization filtering. A similar approach can be implemented for OBQuery.&lt;br /&gt;
&lt;br /&gt;
=== When flushing/committing a trigger throws an exception, but I can't see/display the real trigger message ===&lt;br /&gt;
&lt;br /&gt;
Hibernate and JDBC will wrap the exception thrown by the trigger in another exception (the java.sql.BatchUpdateException) and this exception is sometimes wrapped again. Also the java.sql.BatchUpdateException stores the underlying trigger exception in the nextException and not in the cause property. The following method can help you to get to the underlying trigger message:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;private String getExceptionMessage(Throwable t) {&lt;br /&gt;
    if (t.getCause() instanceof BatchUpdateException&lt;br /&gt;
        &amp;amp;&amp;amp; ((BatchUpdateException) t.getCause()).getNextException() != null) {&lt;br /&gt;
      final BatchUpdateException bue = (BatchUpdateException) t.getCause();&lt;br /&gt;
      return bue.getNextException().getMessage();&lt;br /&gt;
    }&lt;br /&gt;
    return t.getMessage();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{(!)| Openbravo API provides a method called '''getUnderlyingSQLException()''' on the '''DbUtility''' class which already does this checks and covers other cases also.}}&lt;br /&gt;
&lt;br /&gt;
=== Test your HQL: the HQL Query Tool ===&lt;br /&gt;
&lt;br /&gt;
Openbravo forge contains a [http://forge.openbravo.com/projects/hqlquerytool module] which offers a query tool which allows you to try a HQL query directly in the Openbravo web interface. The HQL Query Tool is also available through the central repository. See [http://forge.openbravo.com/plugins/mwiki/index.php/Hqlquerytool/User_Manual here] for the manual of this utility module.&lt;br /&gt;
&lt;br /&gt;
=== How can I see what SQL is executed? ===&lt;br /&gt;
&lt;br /&gt;
To see the SQL queries fired by Hibernate, the following log4j property has to be set (in the WEB-INF/classes/log4j.properties or better in openbravo/src/log4j.properties):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;### log just the SQL&lt;br /&gt;
log4j.logger.org.hibernate.SQL=debug&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For seeing the binding of values to query parameters set this property:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;### log JDBC bind parameters ###&lt;br /&gt;
log4j.logger.org.hibernate.type=error&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If it does not work for you, it is possible that the log4j.properties file is read from another location than you expect. To see where log4j reads its properties from set this jvm parameter:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;-Dlog4j.debug&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== My query does not return my newly created object! ===&lt;br /&gt;
&lt;br /&gt;
This can occur when you do not explicitly set the active property to true in the new business object.&lt;br /&gt;
&lt;br /&gt;
The main Openbravo query classes ([[Data_Access_Layer#OBCriteria|OBCriteria]] and [[Data_Access_Layer#OBQuery|OBQuery]]) automatically add different filter criteria. One of the filter criteria is the active property. As a default the query classes will only return objects with active is true (or 'Y' in the database).&lt;br /&gt;
&lt;br /&gt;
When creating a business object the active property has to be explicitly set to true (setActive(true)). This ensures that the active-filter will not miss it in queries.&lt;br /&gt;
&lt;br /&gt;
=== My query does not return anything! ===&lt;br /&gt;
&lt;br /&gt;
There are cases where Hibernate will perform an inner-join when executing a query. If there is no related data in the joined table then the complete query will return nothing. &lt;br /&gt;
&lt;br /&gt;
As an example take the following query:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sql&amp;quot;&amp;gt;select p.id, p.image from Product as p&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This query seems pretty simple. However, in fact the image is a seperately persisted object and a many-to-one reference from the product to the image table. This query therefore results in an inner-join to the image table. In this case that table was empty and nothing was returned.&lt;br /&gt;
&lt;br /&gt;
To solve this issue, the image has to be joined in an outer join:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sql&amp;quot;&amp;gt;select p.id, p.image from Product as p left outer join p.image&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== not-null property references a null or transient value: *.creationDate ===&lt;br /&gt;
&lt;br /&gt;
This exception is thrown when you try to save a new business object with its Id set. It makes sense to set an id if you want to control the id-setting (and not let hibernate create one for you). However, if the id is set then Hibernate/Openbravo will think it is an existing object and not set the audit info properties.&lt;br /&gt;
&lt;br /&gt;
To solve this also call setNewOBObject(true) on the new business object. This signals to Openbravo that the object is new eventhough its id is set.&lt;br /&gt;
&lt;br /&gt;
=== not-null property references a null or transient value: *.updated ===&lt;br /&gt;
Same issue as the previous one.&lt;br /&gt;
&lt;br /&gt;
=== org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: .... ===&lt;br /&gt;
&lt;br /&gt;
This exception occurs when you save an object which refers to another object which has not yet been saved. It applies to so-called many-to-one references, for example from Order to Currency (many orders use the same currency). Openbravo maps the many-to-one associations without cascading. This is for performance reasons.&lt;br /&gt;
&lt;br /&gt;
To prevent this exception save the refered-to instance before the refering instance.&lt;br /&gt;
&lt;br /&gt;
Note that in practice this exception does not happen that often as most references are from transactional to master data, and master data is traditionally setup before transactional data is created. &lt;br /&gt;
&lt;br /&gt;
The import data/REST webservices take care of persisting objects in the correct order so therefore this exception does not occur when importing data through these processes.&lt;br /&gt;
&lt;br /&gt;
=== Performance: getting the id of a BaseOBObject ===&lt;br /&gt;
To improve performance of single-ended associations, the DAL makes use of the Hibernate proxy functionality. The Hibernate proxy functionality wraps an object inside a Hibernate (cglib) proxy object. The Hibernate proxy object takes care of loading the business object when it is actually accessed and not before. &lt;br /&gt;
&lt;br /&gt;
In many cases a developer just wants access to the id or entityname of an object. To prevent loading of the business object when retrieving just this information, the [https://code.openbravo.com/erp/devel/pi/file/ff43c7c0a97b/src/org/openbravo/dal/core/DalUtil.java DalUtil] class in ''org.openbravo.dal.core'' offers a ''getId'' method and a ''getEntityName'' method. These methods work directly with the HibernateProxy object and do not load the underlying business object.&lt;br /&gt;
&lt;br /&gt;
=== Classloading ===&lt;br /&gt;
The DAL loads classes when initializing the DAL. The DAL as a default uses the context class loader of the thread. In some cases this does not work correctly (for example when using the DAL in Ant). The DAL uses the [https://code.openbravo.com/erp/devel/pi/file/ff43c7c0a97b/src/org/openbravo/base/util/OBClassLoader.java OBClassLoader] class to make the classloader configurable. By calling ''OBClassLoader.setInstance'' with your own OBClassLoader you can control the class loader used by the DAL.&lt;br /&gt;
&lt;br /&gt;
=== NPE when calling a getter of a Business Object ===&lt;br /&gt;
&lt;br /&gt;
All getters of Openbravo business objects return an Object. This is also the case for primitive type properties. In this way Openbravo can support null values in the database (will result in a null value for the property). However, null values result in NPE's when used directly in expressions.&lt;br /&gt;
For example take this code:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;SystemInformation sys = OBDal.getInstance().get(SystemInformation.class, &amp;quot;0&amp;quot;);&lt;br /&gt;
return sys.isEnableHeartbeat();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
When the value of 'enableHeartbeat' is null in the database then the call to isEnableHeartbeat will result in a NPE eventhough the sys variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
The same will happen when using results of getter-calls directly in numeric expressions.&lt;br /&gt;
&lt;br /&gt;
=== DAL Queries do not return or do not see changes in the database ===&lt;br /&gt;
This can occur in the following situation: &lt;br /&gt;
# your program reads objects from the database using the DAL&lt;br /&gt;
# then you update the database directly without going through the DAL (either through direct sql or through a stored procedure), the database updates the objects/data you read through the DAL in step 1&lt;br /&gt;
# then your program uses the same objects as read in step 1 or you read them again from the database &lt;br /&gt;
&lt;br /&gt;
The problem you encounter then is that the objects do not reflect the database state (they are not up-to-date). This is caused by the following:&lt;br /&gt;
&lt;br /&gt;
When Hibernate reads data from the database it is stored in a cache for that session. This session cache is not auto-updated when data changes in the database outside of your hibernate session. So when in the last step you read the objects again from the database, you get the objects from the session-cache and not from the database.&lt;br /&gt;
&lt;br /&gt;
There are 2 solutions:&lt;br /&gt;
# clear the session cache completely&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;OBDal.getInstance().getSession().flush();&lt;br /&gt;
OBDal.getInstance().getSession().clear();&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
# force reread of specific objects&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;OBDal.getInstance().getSession().refresh(myObject);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first approach makes sense if there are many updates in the database or you don't know exactly which objects have changed. The second approach makes sense if you know exactly which object(s) have changed and there are not that many.&lt;br /&gt;
&lt;br /&gt;
In case of the first solution you have to note that objects that have been read (through the DAL) before flushing/clearing can not be used anymore after flush/clear. These objects need to be re-attached to the session or read completely new from the database:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;// reattach an object from the database, only if it is not already part of it&lt;br /&gt;
if (OBDal.getInstance().getSession().contains(myObject)) {&lt;br /&gt;
      OBDal.getInstance().getSession().lock(myObject.getEntity().getName(), myObject, LockMode.NONE);&lt;br /&gt;
}&lt;br /&gt;
// or reread it again, this example assumes that the object &lt;br /&gt;
// is a Business Partner&lt;br /&gt;
BusinessPartner businessPartner = OBDal.getInstance().get(BusinessPartner.class, myPreviouslyReadBP.getId());&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When choosing the 'lock' strategy it is important to choose the correct lock order. First lock the objects which are used by the other objects.&lt;br /&gt;
&lt;br /&gt;
===  ERROR org.hibernate.LazyInitializationException - could not initialize proxy - no Session ===&lt;br /&gt;
&lt;br /&gt;
Hibernate will lazily load objects which are referenced from other objects. So when an object A references an object B, then when reading A from the database, hibernate will create a so-called proxy object B, which is used by A. The B proxy object is not initialized (its data is not set), this initialization is done when B is accessed directly (calling a method on it for example). &lt;br /&gt;
To do this initialization hibernate needs the original hibernate session which was used to read A and create the B proxy object.&lt;br /&gt;
&lt;br /&gt;
The LazyInitializationException occurs when this session is not valid anymore. This happens for example when OBDal.getInstance().commitAndClose() is called, this will close and remove the session. If an uninitialized proxy object is accessed after the commitAndClose call then this exception is thrown.&lt;br /&gt;
&lt;br /&gt;
To prevent this make sure that the objects that you need after the commitAndClose are all initialized. This can be done using the Hibernate.initialize(object) call or by calling an arbitrary method on the object (for example getIdentifier()).&lt;br /&gt;
&lt;br /&gt;
== REST Web Services ==&lt;br /&gt;
&lt;br /&gt;
=== I am getting: 'Caused by: Object Entity(null) is new but not writable' ===&lt;br /&gt;
&lt;br /&gt;
The REST webservice uses the '''default role, client and organization''' of the user. The error ''Caused by: Object Order(null) is new but not writable'' is caused by the fact that either the role or the organization of the user do not allow the writing/creating the entity you are passing in. &lt;br /&gt;
&lt;br /&gt;
See this [http://forge.openbravo.com/plugins/espforum/view.php?group_id=100&amp;amp;forumid=549512&amp;amp;topicid=7012934&amp;amp;page=2 topic] in the Openbravo forum.&lt;br /&gt;
&lt;br /&gt;
And see [https://issues.openbravo.com/view.php?id=13281 this issue] for a related bug fix.&lt;br /&gt;
&lt;br /&gt;
=== My REST webservice does not return anything ===&lt;br /&gt;
&lt;br /&gt;
If your REST webservice only returns this:&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&amp;lt;ob:Openbravo/&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then most of the time the user you used to log in is not authorised to see the requested information.&lt;br /&gt;
Another reason for not seeing information is that the system will automatically add client and organization filtering to the REST query and only show objects which have active==true.&lt;br /&gt;
&lt;br /&gt;
=== Using the REST XML Schema to generate (de-)serialization code ===&lt;br /&gt;
&lt;br /&gt;
The [[REST_XML_Schema_Definition|REST XML Schema]] can be used to generate java or C# code which can be used to (de-)serialize the REST xml content in a type safe way. One thing to be aware of is that primitive typed elements (such as a name or description) have attributes defined in the XML Schema. This means that code generators will not create a String (or other primitive type) member/accessor but will instead use a separate generated type to encapsulate the primitive type value. This separately generated type also holds the other attributes.&lt;br /&gt;
&lt;br /&gt;
See this [http://forge.openbravo.com/plugins/espforum/view.php?group_id=100&amp;amp;forumid=549511&amp;amp;topicid=6994738&amp;amp;topid=6995539 forum post] for a discussion around this.&lt;br /&gt;
&lt;br /&gt;
=== Implementing your own webservice ===&lt;br /&gt;
&lt;br /&gt;
There is a howto on this topic [[How_to_create_a_new_REST_webservice|here]].&lt;br /&gt;
&lt;br /&gt;
=== Firefox Add-On:Poster, to test webservices ===&lt;br /&gt;
To support web service testing, Firefox has a nice add-on: [https://addons.mozilla.org/en-US/firefox/addon/2691 Poster]. This add-on allows you to POST/PUT XML to a URL and do GET and DELETE requests.&lt;br /&gt;
&lt;br /&gt;
=== I am getting: 'message: &amp;quot;OBUIAPP_ActionNotAllowed&amp;quot; type: &amp;quot;user&amp;quot;' ===&lt;br /&gt;
&lt;br /&gt;
You need to add the table you are trying to edit to the user profile in Role Access &amp;gt; Table Access&lt;br /&gt;
&lt;br /&gt;
== Application Dictionary Data Model ==&lt;br /&gt;
&lt;br /&gt;
=== Grids with CLOB fields fail on Oracle ===&lt;br /&gt;
&lt;br /&gt;
Before 3.0MP4 CLOB fields are not supported in the grid in combination with Oracle. From 3.0MP4 onwards this is solved. &lt;br /&gt;
&lt;br /&gt;
See these related issues:&lt;br /&gt;
* https://issues.openbravo.com/view.php?id=18517 (solved in MP4)&lt;br /&gt;
* https://issues.openbravo.com/view.php?id=15556&lt;br /&gt;
* https://issues.openbravo.com/view.php?id=13153&lt;br /&gt;
&lt;br /&gt;
As a workaround: do not show the CLOB fields in the grid in Oracle, the form view should work fine.&lt;br /&gt;
&lt;br /&gt;
=== Using search references not to show a drop down in non-editable fields ===&lt;br /&gt;
&lt;br /&gt;
For the complete reference about Search reference, read the Search section in [[Data_Model|Data Model]] document.&lt;br /&gt;
&lt;br /&gt;
A ''Search'' reference does not show a drop down list but just text box with the selected value and a button to call the search next to it. When the field is non writable the button is not shown and only appears the textbox. &lt;br /&gt;
&lt;br /&gt;
If a column is known to be used always in non-editable fields and it follows the naming rule defined for ''TableDir'' references. It is a good practice not to set it as ''TableDir'' reference but as ''Search'' one, in this case is not necessary to set the ''Reference Search Key'' field. Doing this the generated page will be lighter because instead of generating a drop down list with all the elements it will just generate a textbox.&lt;br /&gt;
&lt;br /&gt;
=== Application Dictionary syntax ===&lt;br /&gt;
&lt;br /&gt;
Application Dictionary contains many examples of '''default values''', '''display logics''', '''read-only logics''' and '''validations''' syntax. Just query your database to find out how they are defined (you can execute these queries inside Openbravo ERP, logged with an user with ''System Administrator'' role inside ''Application Dictionary || Maintenance || SQL Query''). Find more info about dynamic expressions in the [[Dynamic_Expressions|''Dynamic Expressions'']] chapter of the Developer's Guide.&lt;br /&gt;
&lt;br /&gt;
====Default values====&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sql&amp;quot;&amp;gt;SELECT t.name AS table_name, c.name AS column_name, c.defaultvalue AS default_value&lt;br /&gt;
FROM ad_table t, ad_column c  &lt;br /&gt;
WHERE c.defaultvalue is not null&lt;br /&gt;
--AND c.defaultvalue like '%+%'&lt;br /&gt;
--AND c.defaultvalue like '%SQL%'&lt;br /&gt;
AND c.ad_table_id = t.ad_table_id&lt;br /&gt;
ORDER BY t.name, c.name;  &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Display logics====&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sql&amp;quot;&amp;gt;SELECT w.name AS window, t.name AS tab, f.name AS field, f.displaylogic AS display_logic  &lt;br /&gt;
FROM ad_window w, ad_tab t, ad_field f&lt;br /&gt;
WHERE f.displaylogic IS NOT NULL&lt;br /&gt;
AND w.ad_window_id = t.ad_window_id&lt;br /&gt;
AND t.ad_tab_id = f.ad_tab_id&lt;br /&gt;
ORDER BY w.name, t.name, f.name;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Example 1'''&lt;br /&gt;
If you want to restrict the access to a child tab based on the value of a field of its father tab you have to:&lt;br /&gt;
# Mark the column of the field inside the father's tab as ''Stored in Session''.&lt;br /&gt;
# Add to all the fields of the child tab a display logic in the form @Father_Column_Name@ = 'Value'&lt;br /&gt;
See, for instance, how it is done in ''Master Data Management || Product Setup || Attribute  ||  Attribute  &amp;gt;&amp;gt;  Attribute Value'' when un-checking ''List'' check-box in ''Attribute'' tab by querying:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sql&amp;quot;&amp;gt;SELECT w.name AS window, t.name AS tab, f.name AS FIELD, f.displaylogic AS display_logic &lt;br /&gt;
FROM ad_window w, ad_tab t, ad_field f&lt;br /&gt;
WHERE f.displaylogic IS NOT NULL&lt;br /&gt;
AND w.ad_window_id = t.ad_window_id&lt;br /&gt;
AND t.ad_tab_id = f.ad_tab_id&lt;br /&gt;
AND UPPER(t.name) LIKE '%ATTRIBUTE VALUE%'&lt;br /&gt;
ORDER BY w.name, t.name, f.name;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Read-only logics====&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sql&amp;quot;&amp;gt;SELECT t.name AS table_name, c.name AS column_name, c.readonlylogic AS read_only_logic&lt;br /&gt;
FROM ad_table t, ad_column c  &lt;br /&gt;
WHERE c.readonlylogic IS NOT NULL  &lt;br /&gt;
AND c.ad_table_id = t.ad_table_id&lt;br /&gt;
ORDER BY t.name, c.name;&lt;br /&gt;
&amp;lt;/source&amp;gt;  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Validations====&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sql&amp;quot;&amp;gt;SELECT t.name AS table_name, c.name AS column_name, vr.code AS validation_rule  &lt;br /&gt;
FROM ad_val_rule vr, ad_table t, ad_column c  &lt;br /&gt;
WHERE c.ad_val_rule_id = vr.ad_val_rule_id  &lt;br /&gt;
AND c.ad_table_id = t.ad_table_id&lt;br /&gt;
ORDER BY t.name, c.name;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build tasks ==&lt;br /&gt;
&lt;br /&gt;
=== After export.database all the xml headers use double quotes ===&lt;br /&gt;
&lt;br /&gt;
After export.database you see this in the top of the header:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
when diffing this with the repository you see that the repository has this (uses single quotes):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;xml&amp;quot;&amp;gt;&amp;lt;?xml version='1.0' encoding='UTF-8'?&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The standard in Openbravo is to use single quotes. To solve this issue copy to '''''src-db/database/lib/wstx-asl-3.0.2.jar''''' file to ''lib'' folder inside your Ant folder.&lt;br /&gt;
&lt;br /&gt;
Once it is copied to the ''lib'' folder inside your Ant folder, make sure the files have execution rights.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Concepts]]&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
		
	</entry>
</feed>