aspose file tools*
The moose likes JDBC and the fly likes long can not be deferenced Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "long can not be deferenced" Watch "long can not be deferenced" New topic
Author

long can not be deferenced

Roberto Favaro
Greenhorn

Joined: Mar 23, 2004
Posts: 24
Can anyone help me avoid my error.Long cannot be deferenced. OrderId must be of type long

Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Are you sure that is the code that is causing the error? What you've posted won't compile, but for a different reason than your error.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Roberto Favaro
Greenhorn

Joined: Mar 23, 2004
Posts: 24
I have a huge dao which is talking to a database.I want to check if the id exists but the .length() method is the problem as the id (type long) cannot be deferenced
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Two problems:
  • long is a primitive type.
  • The type Long does not have a length() method.

  • Roberto Favaro
    Greenhorn

    Joined: Mar 23, 2004
    Posts: 24
    Thank you.Is there another way to write this without having to change the type
    Paul Sturrock
    Bartender

    Joined: Apr 14, 2004
    Posts: 10336

    I dunno, its hard to understand what you are trying to do. What it looks like you might be trying to do is see if a value has been assigned to orderId and if it has been return 0. Is that right?
    Roberto Favaro
    Greenhorn

    Joined: Mar 23, 2004
    Posts: 24
    Yes......I changed my code to use a primaryKey generator to generate a unique Id and removed the need for a check.Thank you for ure help
     
    Don't get me started about those stupid light bulbs.
     
    subject: long can not be deferenced