openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chuong Pham (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (OPENJPA-1976) EntityManager.find method cause errors
Date Mon, 11 Apr 2011 04:29:05 GMT

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

Chuong Pham commented on OPENJPA-1976:
--------------------------------------

Thanks for the info, Rick.

As for passing a String value as a second parameter to the EntityManager.find method, I realised
after I posted the issue that as per OpenJPA doc that the second parameter can only accepts
a primary key value. I suppose my comment regarding passing a String value to the EntityManager.find
method should have been: Can I pass a String value as a second parameter to the EntityManager.find
method in a future release of the OpenJPA? I noticed that some of the examples I found for
EclipseLink suggested that it can accept a String and not restricted to a primary key. I was
hoping that OpenJPA can do the same - well not, in the current release anyway. The reason
for passing a [hashed] string is because I'm getting the value of the id parameter from the
URL to be used with the EntityManager.find method, for example bookview?id=214736890D96ED598E1D3050F1F025A7
as opposed to bookview?id=5148 - which is the actual primary key of the record in the table.
For me, it would be "safer" to pass a hashed value to prevent anyone from parameter tampering
- even though I have server-side validation enforced on parameters - still IMHO, it would
be a safer alternative to passing a primary key. The hashed value I have created [via database
trigger] uses AES encryption and, as far as I know, has not been compromised by collusion
or otherwise. I hope this explains why I am using a String as opposed to a Long value.

As for the IllegalStateException error with Glassfish, I have restarted Glassfish several
times, even went so far as to delete the build directory of the project and delete the eclipseApps
and autodeploy directories under Glassfish and start again - all without success. Also, I
have logged a post in the Glassfish forum - but so far, the responses I have received does
not indicate that this might be a Glassfish issue, though I'm waiting for more responses to
confirm that. I apologise in advance if this IS a Glassfish issue and I have wasted your time.


Thanks for the link to the OpenJPA User Mailing List. Much appreciated. I'll post the question
there and see if anyone else has a similar issue as I have.

Regards
Chuong

> EntityManager.find method cause errors
> --------------------------------------
>
>                 Key: OPENJPA-1976
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1976
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jpa
>    Affects Versions: 2.1.0
>         Environment: Glassfish 3.1, JSF 2.1.0, Apache OpenJPA 2.1.0, MySQL 5.5.10, Eclipse
Helios IDE, Windows XP Service Pack 3
>            Reporter: Chuong Pham
>            Assignee: Rick Curtis
>              Labels: features, test
>         Attachments: ENTITY.txt, SCENARIO 1 STACKTRACE.txt, SCENARIO 2 STACKTRACE.txt
>
>
> Scenario 1: The EntityManager.find method is unable to pass a String value as its second
parameter and caused the following error:
> <openjpa-2.1.0-r422266:1071316 nonfatal user error> org.apache.openjpa.persistence.ArgumentException:
The given value "214736890D96ED598E1D3050F1F025A7" cannot be converted into an identity for
"com.ckd.model.BookModel".  The value is the wrong type (java.lang.String).
> java.lang.NumberFormatException: For input string: "214736890D96ED598E1D3050F1F025A7"
> It seems from the errors above that the EntityManager.find method will only accept a
numeric value as its second parameter.
> Scenario 2: The EntityManager.find method is unable to pass a Long value and caused the
following error:
> <openjpa-2.1.0-r422266:1071316 fatal user error> org.apache.openjpa.persistence.ArgumentException:
An error occurred while processing registered class "class com.ckd.model.BookModel".
> java.lang.IllegalStateException: WEB9031: WebappClassLoader unable to load resource [org.apache.openjpa.util.LongId],
because it has not yet been started, or was already stopped
> The columns used for testing are from a MySQL 5.x table and have the following definitions:
> ID SMALLINT(5)
> HASHID VARCHAR(32)
> The value of HASHID is used to test Scenario 1; while the value of ID is used to test
Scenario 2.
> Conclusion: The above scenarios show that the EntityManager.find method is currently
unusable/buggy and needs to be investigated for the next release.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message