272 words

Attempt to store an instance of a non persistable type java.net.URL

#1
2012-02-07 06:16

The following works in EclipseLink+MySQL and EclipseLink+Oracle:

    public Link(String name, String $url) //throws MalformedURLException
    {
        this.name = name;
        try {
            url = new URL($url);
        } catch (MalformedURLException ex) {
            log_error(ex);
        }
    }
 
    private URL url;
 
    public URL getUrl() {
        return url;
    }
 
    public void setUrl(URL url) {
        this.url = url;
    }

I can rewrite this to simply check whether it is a valid URL $url string and storing it.

I can return getURL also as transient to keep my public contract.

But it would be nice to have URLs stored directly.

 

webel
webel's picture
Joined on 2011-05-27
User Post #33
#2
2012-02-07 06:19

ObjectDB supports persisting serializable types, so it should also support URL. This ability is disabled by default but you may enable it by changing that default configuration

Note: This is a client side setting, so in client-server mode it has to be applied on the client side.

There are several reasons why serialization is disabled by default:

  • It is less portable since such data is not expected to be accessible by future versions of ObjectDB for .NET and for other platforms.
  • It is less efficient than simple types and embedded objects.
  • Support of serialized objects in the Explorer is very limited.
ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
support
support's picture
Joined on 2010-05-03
User Post #909

Post Reply

Please read carefully the posting instructions - before posting to the ObjectDB website.

  • Use ctrl + right click to open the browser context menu in the editing area (e.g. for using a browser spell checker).
  • To insert formatted lines (e.g. Java code, stack trace) - select a style in the toolbar and then insert the text in the new created block.
  • Avoid overflow of published source code examples by breaking long lines.
  • You may mark in paragraph code words (e.g. class names) with the code style (can be applied by ctrl + D).
  • Long stack traces (> 50 lines) and complex source examples (> 100 lines) should be posted as attachments.
Attachments:
Maximum file size: 32 MB
Cancel