English 中文(简体)
Java 持续存在, d实体与其他模型之间的通信
原标题:Java persistence, communications between db entities and other models

我在贾瓦的申请书中利用TongLink的永久图书馆与MySQL db。

I ve developed the class library which is used by several desktop applications, it contains some classes that are specific for my project. Classes are linked to each other, generally with one-to-many relationships.

我想将非行实体班和具体项目班分开。

我应如何发展这几类人之间的沟通(继承、使用或某类)。 如何在将具体项目类别装入数据库时发展这种关系?

最佳回答

我猜测,自其桌面应用以来,它是一种基于“全心”的应用。 因此,MVC的建筑在此最为合适。 我也认为,你必须使用 Java豆来方便地利用这一模式。

首先界定了所有定义的模式。

说 明

        class person
{
        public PropertyChangeSupport propertyChange = new PropertyChangeSupport(this);

        private String firstName;
        private String middleName;
        private String lastName;
        private int gender;
        private Integer age;
        .
        .

        set Fname(String firstName)
        {
                      propertyChangeSupport.firePropertyChange("firstName",this.firstName,this.firstName         = firstName);
        }
        .
        .
        .
        public void setPropertyChange(PropertyChangeSupport propertyChange) {
                this.propertyChange = propertyChange;
        }


         public PropertyChangeSupport getPropertyChange() {
                return propertyChange;
         }

        public void removePropertyChangeListener(PropertyChangeListener listener) {
        propertyChange.removePropertyChangeListener(listener);
        }

}

现在我们需要一个模式提供者,这将是一个单一州模式。

class PersonMOdelProvider
{

private static List<Person> lst ;
private static PersonMOdelProvider content;
private PersonMOdelProvider()
{
  // Get data from data base layer.
  lst = new ArrayList<Person>();
  //load the list from database
}

public static PersonModelProvider getInstance()
{
 if (content!=null) return content;
content = new PersonMOdelProvider();
return content;
}

.
.
.
set ... get methods for binding db with model. 

}

现在,在“倡议”方面,你首先需要了解模式提供者,并通过模型提供者进行进一步的互动。

问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签