All Questions
520
questions
30
votes
3
answers
14k
views
Using javafx.beans properties in model classes
Is it a correct practice to use JavaFX beans properties in the model classes?
I wonder if it is a good practice to use properties in model classes to be able to bind them easier with the view ...
23
votes
15
answers
6k
views
Programming against interfaces: Do you write interfaces for all your domain classes?
I agree, that programming against interfaces is a good practice. In most cases in Java "interface" in this sense means the language construct interface, so that you write an interface and an ...
23
votes
1
answer
11k
views
JavaBean wrapping with JavaFX Properties
I want to use JavaFX properties for UI binding, but I don't want them in my model classes (see Using javafx.beans properties in model classes). My model classes have getters and setters, and I want to ...
20
votes
3
answers
19k
views
Difference among Model, javabean and POJO
I started learning MVC with spring. I have heard lot of time Bean, that contains setter and getter. Model is basically what data flows around, and Pojo which is same as Bean. But I am really confused ...
13
votes
7
answers
8k
views
How to model an amount of Money in Java [closed]
Can anybody recommend a class library or a design pattern that models amounts of Money?
I guess it should support:
multiple currencies
a mechanism to indicate the number of decimals
math (respecting ...
13
votes
5
answers
5k
views
Best practice for adding a bidirectional relation in OO model
I'm struggling to come up with a good way of adding a bidirectional relation in OO model. Let's say there is a Customer who can place many Orders, that is to say there is a one-to-many association ...
12
votes
1
answer
13k
views
What is the difference between @ModelAttribute, model.addAttribute in spring?
i am new Spring learner.i'm really confused about what is the difference between two concept:
@ModelAttribute
model.addAttribute
in below there are two "user" value.Are these same thing?Why should ...
10
votes
3
answers
4k
views
MVC architecture DTO/Model mapping/conversion
Using Spring MVC we normally see Controller, Service and Repository layer. The Repository layer uses Entity model which is one to one mapping with database. I thought of following -
Should Service ...
10
votes
5
answers
4k
views
Good tools for versioning REST models for Java
I am looking for good tools to support support changing the version of the model used in REST services. My dream tools would do something like:
My pojo + version 1.0 config/transformer => Service ...
10
votes
4
answers
4k
views
What does flushing thread local memory to global memory mean?
I am aware that the purpose of volatile variables in Java is that writes to such variables are immediately visible to other threads. I am also aware that one of the effects of a synchronized block is ...
9
votes
1
answer
1k
views
Relationship References disbled table while generating model through intellij hibernate persistence tool
I have a table created on mysql with following sql
CREATE TABLE `ssk_cms_category_transaction_type_relation` (
`categoryId` int(11) NOT NULL,
`typeId` int(11) NOT NULL,
`createdTime` timestamp ...
9
votes
6
answers
4k
views
Are there patterns for model / entity classes
What is the best approach to take when you are pulling model objects from multiple datasources?
For example I have an application has has some data stored in a mySQL database using hibernate. What ...
9
votes
3
answers
29k
views
Java Model Objects design
So I've been reading some Effective Java! And one of the most inspiring sections of the book is the Immutable Object/Builder section where Bloch writes about the "Builder" - class instead of just ...
8
votes
3
answers
19k
views
How do I clear a JTree model?(Removing all nodes)
So this is a method of mine that is called everytime a new node is added.I need the model cleared everytime.The DefaultListModel has a .clear() method.The DefaultTreeModel does not.Help?
...
8
votes
3
answers
3k
views
Parsing and modification of SQL statements in Java
Does anyone know about a SQL statements parser, in Java, that would allow having an Object representation of a SQL query, allow modifying this representation and generate back the updated SQL ...
8
votes
3
answers
3k
views
Java model validation
We are looking for a Java library/system/package which not only does basic validation but also can do relationship validation. We need to be able to express validation criteria which is based on ...
7
votes
1
answer
7k
views
MVC - do I need to use Controller in the View?
As I know in the standard implementation of the MVC we pass Controller and Model to the View
But Im a little bit disagree with this idea. I dont want my view to know about both controller and model (...
7
votes
5
answers
852
views
Hierarchical object model with property inheritance and event bubbling?
I'm writing a document-based client application and I need a DOM or WPF-like, but non-visual model that:
Is a tree composed of elements
Can accept an unlimited number of custom properties that
get/...
6
votes
2
answers
14k
views
How do I load a Weka model in Java?
I have saved the result of a Weka classification by right-clicking on the model and selecting "save model". Now, I want to load it and work with it in my Java application. How can I do that? ...
6
votes
3
answers
8k
views
Kotlin Data class v/s open class?
As I am converting my java project to kotlin project, I came
to know about data classes in kotlin(replacement of Java model classes).
Now I have a requirement for my kotlin data class to support ...
6
votes
2
answers
6k
views
Difference between Model classes and DAO classes
I'm new to java based web applications. I have to create a dynamic web project using MVC structure. So far I created three packages and some java classes like below. I have some doubts about these ...
6
votes
2
answers
9k
views
What is the conceptual difference between a Model and a Diagram in software development
I have seen that there is a clear distinction between models and diagrams in software development, but I cant quite fork out the difference between models and diagrams.
For example there is a Use ...
6
votes
1
answer
3k
views
Update JMenu display names
So I have a JMenu with a few submenus inside. The names of those menus are set by getting the name of a 1 of 4 players. I added a MenuListener to the JMenu to update those names using
menu.setName(...
6
votes
1
answer
4k
views
Using composition as a workaround for inheritance in realm (android)?
In my app, I am using realm as a database platform. Realm has been great thus far- super easy to use, make queries, etc.-though, I have two qualms with it that I am trying to work around.
1) Realm ...
6
votes
1
answer
29k
views
How is used @RequestAttribute and @ModelAttribute annotation in this Spring MVC showcase example?
I am pretty new in Spring MVC.
In this period I am studying the Spring MVC showcase example downlodable from STS dashboard.
I am having some problems understanding how Custom Resolvable Web ...
5
votes
1
answer
16k
views
Error MVC org.springframework.validation.BeanPropertyBindingResult: 1 errors with array
Hi I try pass an array in a bean from jsp to java.
@ModelAttribute("areasActividadAdminBean")AreasActividadAdminBean areasActividadAdminBean
Agrupacion[] listaAgrupaciones = x;
model.addAttribute("...
5
votes
2
answers
3k
views
How to merge EMF models programmatically in Java?
Is there a way to combine multiple Ecore models (2 or more) in a single Ecore model programmatically in Java? With all models conform to the same metamodel.
In:
Model1 conforming to metamodelX
...
5
votes
3
answers
4k
views
Java Swing: List Models and Collections
I am currently writing a program which is having a lot of code duplication between the GUI aspect and the data storage aspect, and I was wondering if my proposed solution follows acceptable design ...
5
votes
2
answers
2k
views
Multiple DAOs with dependencies (foreign key)
I am creating an application with database access. I do not use JPA nor JooQ or other frameworks for reasons (and do not want to. Also this is not important for my question). So I use JDBC and write ...
4
votes
2
answers
8k
views
Alternative Annotations to Java Bean Validation Without Using Hibernate
I am working on a project that I need to put some limitations/constrains on the fields of the models(e.g. "String name" field should not exceed 10 characters) . I can only find Java Bean Validation ...
4
votes
3
answers
673
views
Two classes with almost duplicate code inside
At this moment, I have two classes: UserHibernateDao and TicketHibernateDao:
import java.util.List;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import model.dao.Dao;
...
4
votes
4
answers
5k
views
Java: How to think about Modelling a Markov Chain?
I have a program that I am trying to make a Markov text generator for. I plan on splitting some text up at a set interval and then storing that into a class. The problem that I don't know how to solve ...
4
votes
2
answers
2k
views
Java 3D LWJGL collision
I am making a 3D Java game with the LWJGL library, and I was wondering how to add collision detection, so that the player does not go through models.
I am using OBJ models.
Here is the OBJLoader ...
4
votes
2
answers
3k
views
Filter through model or dao?
How should one go about filtering a series of domain objects according to user-defined criteria? Should the filtering methods be in the model or should they be in the DAO?
4
votes
2
answers
13k
views
Wicket: How to change label's text on textarea's onkeyup?
How do I change label's text on textarea's onkeyup? I've tried this but does not work:
Form form;
TextArea ta;
MyLabel resultDiv;
/**
* Constructor that is invoked when page is invoked without ...
4
votes
2
answers
592
views
MVC one to many relationship in model
So I'm new to MVC and I'm creating Model classes which have 1:N relationship with another classes, for example
public class Post {
private int id;
private String message;
// setters and ...
4
votes
2
answers
1k
views
Models not being saved in Play Framework
Assume a model named User:
@Entity
public class User extends Model {
@Id
@Constraints.Min(10)
public Long id;
@Constraints.Required
public String username;
@Constraints....
4
votes
2
answers
172
views
Can this object model for my Java application be improved?
I'm designing a Java application that will be used by contractors to diagram residences. Currently, I'm in the modeling phase and am creating a UML class diagram. My issue is that I'm not sure the ...
4
votes
1
answer
742
views
Typed DefaultListModel to avoid casting
Is there a way in java to have a ListModel that only accepts a certain type?
What I'm looking for is something like DefaultListModel<String> or TypedListModel<String>, because the ...
4
votes
1
answer
6k
views
Open API Maven Plugin - Generate only specifc API model classes
I am working on generation of model classes by Open API Maven plugin which I need to use in my business logic. The api is generated by other team and given to us. It has lot of model classes ...
4
votes
3
answers
770
views
Model from Caterpillar to Butterfly in Java
I was recently asked this question in an interview:
Model animals that change their behaviour over time.
Can you model a butterfly?
A butterfly can fly * A butterfly does not make ...
4
votes
2
answers
3k
views
cast mongodb query result to data model class in java
I want to create a data model of java class, so that I can automatically get some Properties of the data Model which retrieved from the dbcollection of mongodb by using method defined in the class. ...
4
votes
1
answer
570
views
Java MVC, Share Models between controllers?
I am implementing the MVC structure that this website talks about http://www.oracle.com/technetwork/articles/javase/mvc-136693.html
I am struggling to work out of to open new windows that have a new ...
3
votes
4
answers
4k
views
Why do I sometimes get blank JLists after updating contents through the list model?
I have a recurring problem where I have a JList which I wish to update with new contents. I'm using a DefaultListModel which provides methods for adding new content to the list but when using these ...
3
votes
5
answers
2k
views
Java swing: Jtable with many models and custom renderer
I have a jtable in which i recolor rows depending on values from model, something like this:
resultTable = new javax.swing.JTable(){
private Border outside = new MatteBorder(1, 0, 1, 0, Color....
3
votes
1
answer
8k
views
Difference between @Inject and @ValueMapValue annotations
While reading AEM documentation about using models,
I couldn't figure out what is the difference between @Inject and @ValueMapValue annotation above the field.
I tried using both, and they both ...
3
votes
5
answers
230
views
"Value" member field can be one of four different types - best design?
I have a class called "DataModel" or something, which is basically a unit of data which can be either a string or a number or a date or a boolean with various (identical) attributes.
What is the best ...
3
votes
2
answers
1k
views
Constructor with many required parameters
If I have a constructor for an immutable object that requires several (4+ parameters), is having a single constructor with all the required parameters the correct approach?
I feel this becomes a ...
3
votes
4
answers
3k
views
Communication between Models in MVC-based GUI
I am developing my GUI according to the MVC pattern:
-GUIview: Swing components (JFrame and several JTables).
-GUIcontroller: listeners (added here, and defined here in Inner classes)
-GUImodel: ...
3
votes
2
answers
9k
views
How to update an Object in play framework?
How do I edit an existing object in the database? For example, if I have a model like this:
class Topic{title,content,author}, when I edit and save the object I do not want to add the "author" ...