在Java桌面应用程序中持久保存数据的最佳方法是什么?

编程入门 行业动态 更新时间:2024-10-26 04:31:21
本文介绍了在Java桌面应用程序中持久保存数据的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我的桌面应用程序中有一棵大的Java对象,正在尝试确定将它们作为文件持久保存到文件系统的最佳方法.

I have a large tree of Java Objects in my Desktop Application and am trying to decide on the best way of persisting them as a file to the file system.

我的一些想法是:

  • 使用DataOutputStream滚动我自己的序列化器:这将使我对文件中的内容拥有最大的控制权,但要以微管理方式为代价.

  • Roll my own serializer using DataOutputStream: This would give me the greatest control of what was in the file, but at the cost of micromanaging it.

使用ObjectOutputStream及其各种相关类的直接旧序列化:虽然我发现数据很脆弱,但是我没有将其出售.更改任何对象的结构都会破坏它的序列化实例.因此,我陷入了可怕的版本控制噩梦.

Straight old Serialization using ObjectOutputStream and its various related classes: I'm not sold on it though since I find the data brittle. Changing any object's structure breaks the serialized instances of it. So I'm locked in to what seems to be a horrible versioning nightmare.

XML序列化:虽然不那么脆弱,但是直接进行序列化的速度要慢得多.可以在我的程序之外进行转换.

XML Serialization: It's not as brittle, but it's significantly slower that straight out serialization. It can be transformed outside of my program.

JavaDB :考虑到编写JDBC应用程序的舒适性,我考虑了这一点.此处的区别在于,数据库实例仅在打开或保存文件时才会保留.它不是很漂亮,但是...的确可以在以后出现需求时迁移到中央服务器体系结构,并且它提供了以更简单的方式查询数据模型的可能性.

JavaDB: I'd considered this since I'm comfortable writing JDBC applications. The difference here is that the database instance would only persist while the file was being opened or saved. It's not pretty but... it does lend itself to migrating to a central server architecture if the need arises later and it introduces the possibility of quering the datamodel in a simpler way.

我很好奇看到别人的想法.我希望我错过了一种比上述方法更简单明了的方法.

I'm curious to see what other people think. And I'm hoping that I've missed some obvious, and simpler approach than the ones above.

以下是从答案中得出的更多选择:

Here are some more options culled from the answers below:

  • 对象数据库-与ORM方法相比,其基础结构要少得多,并且其执行速度要比XML方法快.谢谢aku
  • An Object Database - Has significantly less infrastructure than ORM approaches and performs faster than an XML approach. thanks aku
推荐答案

db4objects 可能是最佳选择

更多推荐

在Java桌面应用程序中持久保存数据的最佳方法是什么?

本文发布于:2023-11-05 04:01:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1559838.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用程序   持久   桌面   方法   数据

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!