Using @DataSourceDefinition to configure a DataSource
This annotation requires that a data source implementation class (generally from a JDBC driver JAR) be present on the class path (either by including it in your application, or deploying it as a top-level JAR and referring to it via MANIFEST.MF's Class-Path attribute) and be named explicitly.
this annotation bypasses the management layer and as such it is recommended only for development and testing purposes
Defining a Managed DataSource
Installing a JDBC driver as a deployment
Installing the JDBC Driver
deployment or as a core module
managed by the application server (and thus take advantage of the management and connection pooling facilities it provides), you must perform two tasks. First, you must make the JDBC driver available to the application server; then you can configure the data source itself. Once you have performed these tasks you can use the data source via standard JNDI injection.
recommended way to install a JDBC driver into the application server is to simply deploy it as a regular JAR deployment. The reason for this is that when you run your application server in domain mode, deployments are automatically propagated to all servers to which the deployment applies; thus distribution of the driver JAR is one less thing for administrators to worry about.
Note on MySQL driver and JDBC Type 4 compliance: while the MySQL driver (at least up to 5.1.18) is designed to be a Type 4 driver, its jdbcCompliant() method always return false. The reason is that the driver does not pass SQL 92 full compliance tests, says MySQL. Thus, you will need to install the MySQL JDBC driver as a module (see below).
define your module with a module.xml file, and the actual jar file that contains your database driver
content of the module.xml file
Under the root directory of the application server, is a directory called modules
module name, which in this example is com.mysql
where the implementation is, which is the resource-root tag with the path element
define any dependencies you might have. In this case, as the case with all JDBC data sources, we would be dependent on the Java JDBC API's, which in this case in defined in another module called javax.api, which you can find under modules/javax/api/main as you would expect.
mime-mapping is complex field and not resource. that is why it has its own operation handlers add-mime/remove-mime to handle its value. what are you trying to achive can be done by command:
Just bit of a warning when using this, there was a bug in 7.1.1 when you added mime type that prevented server to start.so please use 7.1.2 or 7.2 nightly builds where this is fixed.
best strategies for implementation of equals() and hashcode() in your persistent classes
The general contract is: if you want to store an object in a List, Map or a Set then it is an requirement that equals and hashCode are implemented so they obey the standard contract as specified in the documentation
Why are equals() and hashcode() importantNormally, most Java objects provide a built-in equals() and hashCode() based on the object's identity; so each new() object will be different from all others.
recommend using the "semi"-unique attributes of your persistent class to implement equals() (and hashCode()
The database identifier property should only be an object identifier, and basically should be used by Hibernate only
Instead of using the database identifier for the equality comparison, you should use a set of properties for equals() that identify your individual objects
"name" String and "created" Date, I can use both to implement a good equals() method
Workaround by forcing a save/flush
work around by forcing a save() / flush() after object creation and before insertion into the set
Note that it's highly inefficient and thus not recommended