-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Java object w/o no-arg ctor - am I doing this right?
PostPosted: Mon Sep 29, 2003 9:49 am 
Regular
Regular

Joined: Mon Sep 29, 2003 9:39 am
Posts: 67
Hello,

One of my persistent objects use java.io.File, which has no 0-arg ctor.
Is there a way to just serialize the object into a blob column in SQL Server, or should I use the following method?

public MyClass {
private transient File file;
private String fileName;

private String getFileName() {
return fileName;
}

private void setFileName(String fileName) {
this.fileName = fileName;
file = new File(fileName);
}

public void setFile(File file) {
this.file = file;
}

public File getFile() {
if (file == null) {
file = new File(fileName);
}
return file;
}
}

Where i just persist the state of the File object as a String, and create the object as needed?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 29, 2003 9:56 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
Try to look into implementing your own UserType

_________________
Max
Don't forget to rate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.