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

#1

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 IT Australia, "The Elements of the Web", Specialists in model-based UML, SysML, Enterprise Java, XML, and Drupal CMS web engineering. Dr Darren Kelly, BSc, PhD, https://www.webel.com.au
#2

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)

Post Reply

To post a reply and/or subscribe to update notifications - please login