openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kevin Sutter (JIRA)" <j...@apache.org>
Subject [jira] Commented: (OPENJPA-428) Bad error message regarding "openjpa.Id"
Date Tue, 07 Sep 2010 19:42:32 GMT

    [ https://issues.apache.org/jira/browse/OPENJPA-428?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12906946#action_12906946
] 

Kevin Sutter commented on OPENJPA-428:
--------------------------------------

>From Harold on our Users forum (http://openjpa.208410.n2.nabble.com/Confusing-warning-about-openjpa-jdbc-SynchronizeMappings-tc5495438.html#a5495438)...

Hi Kevin,

I can't offer a fix (yet), but I think I've pinpointed the problem. Here is
a little test case:

import static org.junit.Assert.assertEquals;
import org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl;
import org.junit.Test;

public class ConfigurationTest {

   @Test
   public void cloneTest() {
       JDBCConfigurationImpl config = new JDBCConfigurationImpl();
       JDBCConfigurationImpl newConfig = (JDBCConfigurationImpl)
config.clone();
       assertEquals(config, newConfig);
   }
}

The warning message about the configuration property
openjpa.jdbc.SynchronizeMappings is logged during config.clone().

clone() is implemented by invoking first toProperties(true) and then
fromProperties() on the resulting properties map.

fromProperties() removes all known properties from the map and then issues
warnings for all remaining ones - at least that seems to be the intention.

The problem is that SynchronizeMappings has no default value, or rather a
default value of null. Thus, the map generated by toProperties(true)
contains the key openjpa.jdbc.SynchronizeMappings with a value of null.

fromProperties() in fact only removes the known properties with a non-null
value,  so the key openjpa.jdbc.SynchronizeMappings remains in the map and
causes the warning.

The warning would not appear if clone() invoked toProperties(false), but I'm
not sure if this has any side effects.

Moreover, in my test case, the assertion

  assertEquals(config, newConfig);

fails - now the Javadoc of Object.clone() states that x.clone().equals(x) is
not an absolute requirement (without giving any good reasons), but in this
case I would definitely expect the clone of a configuration to be equal to
the original.

The assertion failure is caused by LockTimeout:0[int] != LockTimeout:0[int],
so it appears that for x of class IntValue the invariant

x.clone().equals(x)

does not hold either (why?).

Incidentally, the comment of ConfigurationImpl.toProperties() is outdated.
It references a non-existing parameter getAll and a non-existing method
getAllProperties().

Hopefully, this is enough input for someone familiar with the implementation
details to come up with a fix...

Best regards,

Harald

> Bad error message regarding "openjpa.Id"
> ----------------------------------------
>
>                 Key: OPENJPA-428
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-428
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 1.0.0
>            Reporter: Vitor Rodrigues
>            Priority: Minor
>         Attachments: OPENJPA-428-test.jar
>
>
> Hi all, this bug is to report a confusing and misplaced error message. Problem is described
below. Feel free to request more info from me.
> When running my project with OpenJPA, I get the following error message:
> 140  INFO   [http-0.0.0.0-8080-Processor23] openjpa.Runtime - Starting OpenJPA 1.0.0
> 380  INFO   [http-0.0.0.0-8080-Processor23] openjpa.jdbc.JDBC - Using dictionary class
"org.apache.openjpa.jdbc.sql.DB2Dictionary".
> 20  WARN   [http-0.0.0.0-8080-Processor25] openjpa.Runtime - The property named "openjpa.Id"
was not recognized and will be ignored, although the name closely matches a valid property
called "openjpa.Id".
> 100  INFO   [http-0.0.0.0-8080-Processor25] openjpa.Runtime - Starting OpenJPA 1.0.0
> 300  INFO   [http-0.0.0.0-8080-Processor25] openjpa.jdbc.JDBC - Using dictionary class
"org.apache.openjpa.jdbc.sql.DB2Dictionary".
> As you can see, the two property names printed are the same, not different or similar.
I retyped all my @Id annotations to make sure there was no special character in one of them
coming from copy&paste.
> Furthermore, I was able to identify that the error message was being printed only when
I removed the @Id annotation from one of my classes (all the other classes still have @Id).
> Here is a sample of my class without @Id annotation:
> @Entity
> @Table(name="TAX", schema="JPA_SC")
> public class Tax  {
> 	
> 	// Class variables  
> 	protected double taxamount;
>  
> 	public Tax(){
> 		
> 	}
> 	
> 	public Tax(double taxamount){
> 		this.taxamount = taxamount;
> 	}
> //plus getter and setter for taxamount
> }
> Regards,
> Vitor Rodrigues

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message