Category Archives: Spring Data JPA

[Solved] AnnotationException: Unknown Id.generator

Hibernate/JPA “AnnotationException: Unknown Id Generator” is very common exception for database based application development this exception occurred because of @SequenceGenerator for @ID not configured properly.

Problem

Running the following Hibernate’s/Spring Boot JPA annotation sequence generator with PostgreSQL/SQL Server database.

   @Id	
	@Column(name="employee_id", nullable=false)	
	@GeneratedValue(strategy = GenerationType.SEQUENCE ,generator="employee_id_seq")
	private Integer employeeId;

Throw the following Hibernate/JPA Unknown Id.generator exception.

Caused by: org.hibernate.AnnotationException: Unknown Id.generator: employee_id_seq
	at org.hibernate.cfg.BinderHelper.makeIdGenerator(BinderHelper.java:413)
	at org.hibernate.cfg.AnnotationBinder.bindId(AnnotationBinder.java:1795)
	at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1229)
	at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:733)

The sequence “employee_user_id_seq” is created in PostgreSQL/SQLServer database, what caused the above “AnnotationException: Unknown Id Generator”?

Solution

When declaring the ID generator startegy in Hibernate’s/JPA, use property with annotation @SequenceGenerator annotation strategy in entity class. Try the above case as following:

     @Id	
	@Column(name="employee_id", nullable=false)	
	@SequenceGenerator(name="my_seq", sequenceName="employee_id_seq")
	@GeneratedValue(strategy = GenerationType.SEQUENCE ,generator="my_seq")
	private Integer employeeId;

Related Posts

Your Feedback Motivate Us

If our FacingIssuesOnIT Experts solutions guide you to resolve your issues and improve your knowledge. Please share your comments, like and subscribe to get notifications for our posts.

Happy Learning !!!

[Solved] No default constructor for entity

This “InstantiationException: No default constructor for entity” is very common for all Hibernate or Spring Boot JPA application development. In this post you will learn about the problem and solutions to resolve it.

Reason of InstantiationException “No default constructor for entity”

The JPA specification requires that all persistent classes have a no-arg constructor. This constructor may be public or protected. Because the compiler automatically creates a default no-arg constructor when no other constructor is defined, only classes that define constructors must also include a no-arg constructor.

In the next sections of post, you will learn about the more detail about the issue and solutions by different ways.

Example

import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;

@Entity
public class Employee {
	@Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    private String name;
 
 
    //parameterize constructor
	public Employee(String name) {
		super();
		this.name = name;
	}
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	@Override
	public String toString() {
		return "Employee [id=" + id + ", name=" + name + "]";
	}  
    
}

Stacktrace

Caused by: org.springframework.orm.jpa.JpaSystemException: No default constructor for entity : com.facingissuesonit.model.Employee
	at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:320) ~[spring-orm-6.0.11.jar:6.0.11]
	at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:771) ~[spring-boot-3.1.2.jar:3.1.2]
	... 8 common frames omitted
Caused by: org.hibernate.InstantiationException: No default constructor for entity : com.facingissuesonit.model.Employee
	at org.hibernate.metamodel.internal.EntityInstantiatorPojoStandard.instantiate(EntityInstantiatorPojoStandard.java:93) ~[hibernate-core-6.2.6.Final.jar:6.2.6.Final]
	... 23 common frames omitted

Problem

The above Employee entity class is not having the default no-arg constructor, due to JPA specification it’s required and through above InstantionException or JPASystemException.

Solutions

There are many ways to resolve this issue:

Solution 1: Add Default Constructor

You can create Default Constructor as below with public or protected scope.,

import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;

@Entity
public class Employee {
	@Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    private String name;
    
    //Default Constructor
    public Employee() {
	}
    //parameterize constructor
	public Employee(String name) {
		super();
		this.name = name;
	}
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	@Override
	public String toString() {
		return "Employee [id=" + id + ", name=" + name + "]";
	}  
    
}

Solution 2: Lombok Annotations

Lombok provide good annotations to reduce effort of development and clean code, once you use the annotation it’s automatically generate the code on compile classes. Specific to this issue you can use the above class as below with different annotations.

See Also:

@NoArgsConstructor

When use @NoArgsConstructor the Lombok will generate default constructor of class on compile time. Ex:

import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
@NoArgsConstructor
@Entity
public class Employee {
	@Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    private String name;
    
    //Default Constructor automatically created by lombok
    //public Employee() {
	//}
    //parameterize constructor
	public Employee(String name) {
		super();
		this.name = name;
	}
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	@Override
	public String toString() {
		return "Employee [id=" + id + ", name=" + name + "]";
	}  
    
}

@Data

Lombok @Data annotation more simplified and make your class for boiler plate code. Lombok annotation generate the code for required methods on compile time. Now you can see this class is more clean because no need to write code for getter & setter methods, default constructor, parameterize constructor , toString() method.

import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
@Data
@Entity
public class Employee {
	@Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    private String name;
    
 //all getter, setter methods, default constructors, parameterize constructor, toString() method for all above fields will create by lombok on compile class.
    
}

Conclusion

In this post you have learned about the reason of “InstantiationException: No default constructor for entity” and different solutions to resolve this issue.

References

Related Posts

Your Feedback Motivate Us

If our FacingIssuesOnIT Experts solutions guide you to resolve your issues and improve your knowledge. Please share your comments, like and subscribe to get notifications for our posts.

Happy Learning !!!

[Solved] SQLServerException: The TCP/IP connection to the host ABCKXYZ356, port 1345 has failed

This is most common exception when connecting with database through Spring boot application. It’s happen because of connection failed to the database.

com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host ABCKXYZ356, port 1345 has failed. Error: "ABCKXYZ356. 
Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. 
Make sure that TCP connections to the port are not blocked by a firewall.".    
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:234) ~[mssql-jdbc-8.2.1.jre8.jar:na]    
at com.microsoft.sqlserver.jdbc.SQLServerException.ConvertConnectExceptionToSQLServerException(SQLServerException.java:285) ~[mssql-jdbc-8.2.1.jre8.jar:na]    
at com.microsoft.sqlserver.jdbc.SocketFinder.findSocket(IOBuffer.java:2434) ~[mssql-jdbc-8.2.1.jre8.jar:na]    
at com.microsoft.sqlserver.jdbc.TDSChannel.open(IOBuffer.java:659) ~[mssql-jdbc-8.2.1.jre8.jar:na]    
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:2546) ~[mssql-jdbc-8.2.1.jre8.jar:na]    
at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:2216) ~[mssql-jdbc-8.2.1.jre8.jar:na]    
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:2067) ~[mssql-jdbc-8.2.1.jre8.jar:na]    
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:1204) ~[mssql-jdbc-8.2.1.jre8.jar:na]    
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:825) ~[mssql-jdbc-8.2.1.jre8.jar:na]    
at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138) ~[HikariCP-4.0.3.jar:na]    
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:364) ~[HikariCP-4.0.3.jar:na]    
at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:206) ~[HikariCP-4.0.3.jar:na]    
at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:476) ~[HikariCP-4.0.3.jar:na]    
at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:561) ~[HikariCP-4.0.3.jar:na]    
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115) ~[HikariCP-4.0.3.jar:na]

Reason of Exception

These are main reason of this Exception:

  • This issue can occurred because of wrong properties configured for database connection.
  • This issue can also occurred if the database is not running.
  • This issue can also occurred if database only allow to access through vpn.

Solutions

These are some most common solution to resolve this issue:

  • Verify the connection properties.
  • Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port.
  • Make sure that TCP connections to the port are not blocked by a firewall.
  • Check the vpn connection if DB access allow over the vpn.

Related Posts

Your Feedback Motivate Us

If our FacingIssuesOnIT Experts solutions guide you to resolve your issues and improve your knowledge. Please share your comments, like and subscribe to get notifications for our posts.

Happy Learning !!!

LIQUIBASE Spring Boot Properties

LIQUIBASE is a provider of Spring Boot Data for handling database schemas operations. LIQUIBASE is an Open Source tool which keep track of database schema script revisions. It can handle variety of database types and accepts a variety of file formats for defining the database structures.

See Also:

<dependency>
			<groupId>org.liquibase</groupId>
			<artifactId>liquibase-core</artifactId>
</dependency>

After adding LIQUIBASE dependencies in your application it will automatically download and add the required other dependencies in your application and initialize with default values. You can overwrite these values through application.properties / application.yaml .

Liquibase Configuration Properties

Spring Boot load these properties in LiquibaseProperties class.

NameDefault ValueDescription
liquibase.change-logclasspath:/db/ changelog/db.
changelog-master.yaml
Change log configuration path.
liquibase.check-change-log-locationtrueCheck the change log location exists.
liquibase.contexts Comma-separated list of runtime contexts to use.
liquibase.default-schema Default database schema.
liquibase.drop-firstfalseDrop the database schema first.
liquibase.enabledtrueEnable liquibase support.
liquibase.labels Comma-separated list of runtime labels to use.
liquibase.parameters.* Change log parameters.
liquibase.password Login password of the database to migrate.
liquibase.rollback-file File to rollback SQL statements will be written when an update is performed.
liquibase.url JDBC url of the database to migrate. Incase not set then use the primary configured data source.
liquibase.user Login user of the database to migrate.
LIQUIBASE Spring Boot Properties

References

https://docs.spring.io/spring-boot/docs/1.4.x/reference/html/common-application-properties.html

Happy Learning !!!

Cassandra Spring Boot Properties

Apache Cassandra is a provider of Spring Boot Data for handling NoSQL database operations. Apache Cassandra is a NoSQL distributed database for managing large amounts of data across many servers (clusters) while providing high availability at the cost of decreased consistency. Cassandra high availability is achieved by replicating data to multiple nodes over cluster and allow one or more nodes to go down so that transaction will continue till that point even one server is running.

To use Apache Cassandra in your Spring boot application you have to add this Cassandra starter in your pom.xml .

<dependency>
         <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-cassandra</artifactId>
        <version>2.0.0.M7</version>
</dependency>

After adding Cassandra Database starter in your application it will automatically download and add the required dependencies in your application and initialize with default values. You can overwrite these values through application.properties / application.yaml .

Cassandra Configuration Properties

Spring Boot load these properties in CassandraProperties class.

NameDefault ValueDescription
spring.data.cassandra.cluster-name Cassandra cluster Name.
spring.data.cassandra.compression Compression supported by the Cassandra binary protocol.
spring.data.cassandra.connect-timeout-millis Socket option: connection time out.
spring.data.cassandra.consistency-level Queries consistency level.
spring.data.cassandra.contact-pointslocalhostComma-separated cluster node addresses.
spring.data.cassandra.fetch-size Queries default fetch size.
spring.data.cassandra.keyspace-name Keyspace name to use.
spring.data.cassandra.load-balancing-policy Class name of the load balancing policy.
spring.data.cassandra.port Port of the Cassandra server.
spring.data.cassandra.password Login password of the server.
spring.data.cassandra.read-timeout-millis Socket option: read time out.
spring.data.cassandra.reconnection-policy Reconnection policy class.
spring.data.cassandra.repositories.enabled Enable Cassandra repositories.
spring.data.cassandra.retry-policy Class name of the retry policy.
spring.data.cassandra.serial-consistency-level Queries serial consistency level.
spring.data.cassandra.schema-actionnoneSchema action to take at startup.
spring.data.cassandra.sslfalseEnable SSL support.
spring.data.cassandra.username Login user of the server.
Cassandra Spring Boot Properties

References

https://docs.spring.io/spring-boot/docs/1.4.x/reference/html/common-application-properties.html

Happy Learning !!!

Couchbase Spring Boot Properties

Couchbase is a provider of Spring Boot for handling NoSQL database operations through JSON. Couchbase is NoSQL document oriented distributed database over the cloud or on- premises which perform transactions by JSON and provide unmatched versatility, performance and scalability. To use Couchbase in your Spring boot application you have to add this Couchbase starter in your pom.xml .

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-couchbase</artifactId>
    <version>2.6.3</version>
</dependency>

After adding Couchbase Database starter in your application it will automatically download and add the required dependencies in your application and initialize with default values. You can overwrite these values through application.properties / application.yaml .

Data Couchbase Configuration Properties

Spring Boot load these properties in CouchbaseDataProperties class.

NameDefault ValueDescription
spring.data.couchbase.auto-indexfalsecreate views and indexes automatically.
spring.data.couchbase.consistencyread-your-own-writesBy default Consistency to apply on generated queries.
spring.data.couchbase.repositories.enabledtrueEnable Couchbase repositories.
Data Couch Spring Boot properties

Couchbase Configuration Properties

Spring Boot load these properties in CouchbaseProperties class.

NameDefault ValueDescription
spring.couchbase.bootstrap-hosts Couchbase nodes host/IP address to bootstrap from.
spring.couchbase.bucket.namedefaultbucket name connect to.
spring.couchbase.bucket.password bucket password.
spring.couchbase.env.endpoints.key-value1Number of sockets per node for each Key/value service.
spring.couchbase.env.endpoints.query1Number of sockets per node for each Query (N1QL) service.
spring.couchbase.env.endpoints.view1Number of sockets per node for each view service.
spring.couchbase.env.ssl.enabled Enable SSL support. Enabled automatically if a “keyStore” is provided otherwise specified otherwise.
spring.couchbase.env.ssl.key-store Path to JVM key store which holds the certificates.
spring.couchbase.env.ssl.key-store-password Password used to access the key store.
spring.couchbase.env.timeouts.connect5000Bucket connections timeout. (in milliseconds)
spring.couchbase.env.timeouts.key-value2500Blocking operations performed on a key timeout.( in milliseconds)
spring.couchbase.env.timeouts.query7500N1QL query operations timeout.( in milliseconds)
spring.couchbase.env.timeouts.socket-connect1000Socket connect connections timeout.( in milliseconds).
spring.couchbase.env.timeouts.view7500Regular and geospatial view operations timeout. (in milliseconds).
Couchbase Spring Boot Properties

References

https://docs.spring.io/spring-boot/docs/1.4.x/reference/html/common-application-properties.html

Happy Learning !!!

SOLR Spring Boot Properties

Apache SOLR is a provider of Spring Boot for handling search and indexing of data operations on SOLR content for web. SOLR is a Full Text search engine for content management and also provide REST based SOLR APIs for operations. To use SOLR in your Spring boot application you have to add this SOLR starter in your pom.xml .

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-solr</artifactId>
    <version>2.4.12</version>
</dependency>

After adding SOLR starter in your application it will automatically download and add the required dependencies in your application and initialize with default values. You can overwrite these values through application.properties / application.yaml .

SOLR Configuration Properties

Spring Boot load these properties in SolrProperties class.

NameDefault ValueDescription
spring.data.solr.hosthttp://127.0.0.1:8983/solrSolr host. Ignored if “zk-host” is set.
spring.data.solr.repositories.enabledtrueEnable Solr repositories.
spring.data.solr.zk-host ZooKeeper host address i.e HOST:PORT.
SOLR Spring Boot Properties

References

https://docs.spring.io/spring-boot/docs/1.4.x/reference/html/common-application-properties.html

Happy Learning !!!

Elasticsearch Spring Boot Properties

Elasticsearch is a provider of Spring Boot for handling search and CRUD operations in Elastic Search. Elasticsearch is a Full Text search engine and also provide REST based Elasticsearch APIs for operations. To use Elastic Search in your Spring boot application you have to add this Elasticsearch starter in your pom.xml .

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>

After adding Elasticsearch starter in your application it will automatically download and add the required dependencies in your application and initialize with default values. You can overwrite these values through application.properties / application.yaml .

ElasticSearch Configuration Properties

Spring Boot load these properties in ElasticsearchProperties class.

NameDefault ValueDescription
spring.data.elasticsearch.cluster-nameelasticsearchcluster name.
spring.data.elasticsearch.cluster-nodes Comma-separated cluster node addresses. If not specified, starts a client node.
spring.data.elasticsearch.properties.* Additional properties used to configure the client.
spring.data.elasticsearch.repositories.enabledtrueEnable Elasticsearch repositories.
Elastic Search Spring Boot Properties

JEST (Elasticsearch HTTP client) Configuration Properties

Spring Boot load these properties in JestProperties class.

NameDefault ValueDescription
spring.elasticsearch.jest.connection-timeout3000Connection timeout in milliseconds.
spring.elasticsearch.jest.password Login password.
spring.elasticsearch.jest.proxy.host Proxy host the HTTP client to use.
spring.elasticsearch.jest.proxy.port Proxy port the HTTP client to use.
spring.elasticsearch.jest.read-timeout3000Read timeout. (in milliseconds)
spring.elasticsearch.jest.urishttp://localhost:9200Comma-separated Elasticsearch instances to use.
spring.elasticsearch.jest.username Login user.
JEST/Elastic Search Client Spring Boot Properties

References

https://docs.spring.io/spring-boot/docs/1.4.x/reference/html/common-application-properties.html

Happy Learning !!!

MongoDB Spring Boot Properties

MongoDB is a provider of Spring Boot for handling NoSQL database operations. To use MongoDB  in your Spring boot application you have to add this MongoDB starter in your pom.xml .

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-mongodb</artifactId>
        </dependency>

After adding MongoDB starter in your application it will automatically download and add the required dependencies in your application and initialize with default values. You can overwrite these values through application.properties / application.yaml .

Embedded MongoDB Configuration Properties

Spring Boot load these properties in EmbeddedMongoProperties class.

NameDefault ValueDescription
spring.mongodb.embedded.featuresSYNC_DELAYComma-separated features to enable.
spring.mongodb.embedded.storage.database-dir Directory used for data storage.
spring.mongodb.embedded.storage.oplog-size Maximum size of the oplog in megabytes.
spring.mongodb.embedded.storage.repl-set-name Name of the replica set.
spring.mongodb.embedded.version2.6.10Version of Mongo to use.
MongoDB Embedded Spring Boot Properties

MongoDB Configuration Properties

Spring Boot load these properties in MongoProperties class.

NameDefault ValueDescription
spring.data.mongodb.authentication-database Authentication database name.
spring.data.mongodb.databasetestDatabase name.
spring.data.mongodb.field-naming-strategy USe Fully qualified name of the FieldNamingStrategy.
spring.data.mongodb.grid-fs-database GridFS database name.
spring.data.mongodb.hostlocalhostMongo server host.
spring.data.mongodb.password Login password of the mongo server.
spring.data.mongodb.port27017Mongo server port.
spring.data.mongodb.repositories.enabledtrueEnable Mongo repositories.
spring.data.mongodb.urimongodb://localhost/testMongo database URI.host and port are ignored when setting it.
spring.data.mongodb.username Login user of the mongo server.
MongoDB Spring Boot Properties

References

https://docs.spring.io/spring-boot/docs/1.4.x/reference/html/common-application-properties.html

Neo4J Spring Boot Properties

Neo4J is a provider of Spring Boot for handling Graphical database.  Neo4J is a graphical datbase where need to represent stored data in graphical relational forms. You can add Neo4J  in your Spring boot application by adding Neo4J starter in your pom.xml (Maven) or build.gradle (Gradle).

Maven

<dependency>
        <groupId>org.neo4j.driver</groupId>
        <artifactId>neo4j-java-driver-spring-boot-starter</artifactId>
        <version>4.3.6.0</version>
</dependency>

Gradle

dependencies {
    compile 'org.neo4j.driver:neo4j-java-driver-spring-boot-starter:4.3.6.0'
}

After adding Neo4J starter in your application it will automatically download and add the required dependencies in your application and initialize with default values. You can overwrite these values through application.properties / application.yaml .

Neo4j Configuration Properties

Spring Boot load these properties in Neo4jProperties class.

NameDefault ValueDescription
spring.data.neo4j.compiler Compiler to use.
spring.data.neo4j.embedded.enabledtrueEnable embedded mode when embedded driver is available.
spring.data.neo4j.password Login password of the server.
spring.data.neo4j.repositories.enabledtrueEnable Neo4j repositories.
spring.data.neo4j.session.scopesingletonScope (lifetime) of the session.
spring.data.neo4j.uri URI used by the driver detected by default.
spring.data.neo4j.username Login user of the server.
NEO4J Spring Boot Properties

References

https://docs.spring.io/spring-boot/docs/1.4.x/reference/html/common-application-properties.html

Happy Learning !!!

ATOMIKOS Spring Boot Properties

ATOMIKOS is a provider of Spring Boot for handling transactions atomicity in global transactions involving heterogeneous components. To use ATOMIKOS transaction manager in your Spring boot application you have to add this ATOMIKOS starter in your pom.xml .

<dependency>
      <groupId>com.atomikos</groupId>
      <artifactId>transactions-spring-boot-starter</artifactId>
   </dependency>

After adding ATOMIKOS starter in your application it will automatically download and add the required dependencies in your application and initialize with default values. You can overwrite these values through application.properties / application.yaml .

Atomikos Configuration Properties

Spring Boot load these properties in AtomikosProperties class.

NameDefault ValueDescription
spring.jta.atomikos.connectionfactory.borrow-connection-timeout30Timeout for borrowing connections from the pool. (in seconds)
spring.jta.atomikos.connectionfactory.ignore-session-transacted-flagtrueSet to ignore the transacted flag when creating session.
spring.jta.atomikos.connectionfactory.local-transaction-modefalseSet local transactions are desired.
spring.jta.atomikos.connectionfactory.maintenance-interval60The time between runs of the pool’s maintenance thread. (in seconds).
spring.jta.atomikos.connectionfactory.max-idle-time60The time after which connections are cleaned up from the pool. (in seconds)
spring.jta.atomikos.connectionfactory.max-lifetime0The time that a connection can be pooled for before being destroyed. 0 denotes no limit.(in seconds)
spring.jta.atomikos.connectionfactory.max-pool-size1The maximum pool size.
spring.jta.atomikos.connectionfactory.min-pool-size1The minimum pool size.
spring.jta.atomikos.connectionfactory.reap-timeout0The reap timeout for borrowed connections. 0 denotes no limit.( in seconds)
spring.jta.atomikos.connectionfactory.unique-resource-namejmsConnectionFactoryThe unique name used to identify the resource during recovery.
spring.jta.atomikos.datasource.borrow-connection-timeout30Timeout for borrowing connections from the pool. (in seconds)
spring.jta.atomikos.datasource.default-isolation-level Default isolation level of connections provided by the pool.
spring.jta.atomikos.datasource.login-timeout Timeout for establishing a database connection.(in seconds)
spring.jta.atomikos.datasource.maintenance-interval60The time between runs of the pool’s maintenance thread.(in seconds)
spring.jta.atomikos.datasource.max-idle-time60The time after which connections are cleaned up from the pool.(in seconds)
spring.jta.atomikos.datasource.max-lifetime0The time that a connection can be pooled for before being destroyed. 0 denotes no limit.(in seconds)
spring.jta.atomikos.datasource.max-pool-size1The maximum pool size.
spring.jta.atomikos.datasource.min-pool-size1The minimum pool size.
spring.jta.atomikos.datasource.reap-timeout0The reap timeout for borrowed connections. 0 denotes no limit.(in seconds)
spring.jta.atomikos.datasource.test-query SQL query or statement used to validate a connection before returning it.
spring.jta.atomikos.datasource.unique-resource-namedataSourceThe unique name used to identify the resource during recovery.
spring.jta.atomikos.properties.checkpoint-interval500Interval between checkpoints.
spring.jta.atomikos.properties.default-jta-timeout10000Default timeout for JTA transactions.
spring.jta.atomikos.properties.enable-loggingtrueEnable disk logging.
spring.jta.atomikos.properties.force-shutdown-on-vm-exitfalseSpecify if a VM shutdown should trigger forced shutdown of the transaction core.
spring.jta.atomikos.properties.log-base-dir Directory in which the log files should be stored.
spring.jta.atomikos.properties.log-base-nametmlogTransactions log file base name.
spring.jta.atomikos.properties.max-actives50Maximum active transactions.
spring.jta.atomikos.properties.max-timeout300000Maximum timeout that can be allowed for transactions. (in milliseconds)
spring.jta.atomikos.properties.serial-jta-transactionstrueSpecify if sub-transactions should be joined when possible.
spring.jta.atomikos.properties.service Transaction manager implementation that should be started.
spring.jta.atomikos.properties.threaded-two-phase-committrueUse different (and concurrent) threads for two-phase commit on the resources.
spring.jta.atomikos.properties.transaction-manager-unique-name Transaction manager’s unique name.
ATOMIKOS Spring Boot Properties

References

https://docs.spring.io/spring-boot/docs/1.4.x/reference/html/common-application-properties.html

Happy Leaning !!!

BITRONIX Spring Boot Properties

BITRONIX is a provider of Spring Boot for handling distributed transaction. To use BITRONIX transaction manager in your Spring boot application you have to add this BITRONIX starter in your pom.xml .

<dependency>
     <groupId>org.springframework.boot</groupId>
     <artifactId>spring-boot-starter-jta-bitronix</artifactId>
 </dependency>

After adding BITRONIX starter in your application it will automatically download and add the required dependencies in your application and initialize with default values. You can overwrite these values through application.properties / application.yaml .

BiTronix Configuration Properties

NameDefault ValueDescription
spring.jta.bitronix.connectionfactory.acquire-increment1Number of connections to create when pool grow.
spring.jta.bitronix.connectionfactory.acquisition-interval1Time to wait before trying to acquire a connection again after an invalid connection was acquired.(in second)
spring.jta.bitronix.connectionfactory.acquisition-timeout30Timeout for acquiring connections from the pool. (in second)
spring.jta.bitronix.connectionfactory.allow-local-transactionstrueSet the transaction manager should allow mixing XA and non-XA transactions.
spring.jta.bitronix.connectionfactory.apply-transaction-timeoutfalseSet the transaction timeout should be set on the XAResource when it is enlisted.
spring.jta.bitronix.connectionfactory.automatic-enlisting-enabledtrueSet resources should be enlisted and delisted automatically
spring.jta.bitronix.connectionfactory.cache-producers-consumerstrueSet produces and consumers should be cached.
spring.jta.bitronix.connectionfactory.defer-connection-releasetrueSet the provider can run many transactions on the same connection and supports transaction interleaving.
spring.jta.bitronix.connectionfactory.ignore-recovery-failuresfalseSet recovery failures should be ignored.
spring.jta.bitronix.connectionfactory.max-idle-time60The time after which connections are cleaned up from the pool.(in second)
spring.jta.bitronix.connectionfactory.max-pool-size10The maximum pool size. 0 denotes no limit.
spring.jta.bitronix.connectionfactory.min-pool-size0The minimum pool size.
spring.jta.bitronix.connectionfactory.password The password to use to connect to the JMS provider.
spring.jta.bitronix.connectionfactory.share-transaction-connectionsfalseSet connections in the ACCESSIBLE state can be shared within the context of a transaction.
spring.jta.bitronix.connectionfactory.test-connectionstrueSet connections should be tested when acquired from the pool.
spring.jta.bitronix.connectionfactory.two-pc-ordering-position1The position that this resource should take during two-phase commit (always first is Integer.MIN_VALUE, always last is Integer.MAX_VALUE).
spring.jta.bitronix.connectionfactory.unique-namejmsConnectionFactoryThe unique name used to identify the resource during recovery.
spring.jta.bitronix.connectionfactory.use-tm-jointrue Set TMJOIN should be used when starting XAResources.
spring.jta.bitronix.connectionfactory.user The user to use to connect to the JMS provider.
spring.jta.bitronix.datasource.acquire-increment1Number of connections to create when growing the pool.
spring.jta.bitronix.datasource.acquisition-interval1Time to wait before trying to acquire a connection again after an invalid connection was acquired.(in second)
spring.jta.bitronix.datasource.acquisition-timeout30Timeout for acquiring connections from the pool. (in second)
spring.jta.bitronix.datasource.allow-local-transactionstrueSet the transaction manager should allow mixing XA and non-XA transactions.
spring.jta.bitronix.datasource.apply-transaction-timeoutfalseSet the transaction timeout should be set on the XAResource when it is enlisted.
spring.jta.bitronix.datasource.automatic-enlisting-enabledtrueSet resources should be enlisted and delisted automatically.
spring.jta.bitronix.datasource.cursor-holdability The default cursor holdability for connections.
spring.jta.bitronix.datasource.defer-connection-releasetrueSet the database can run many transactions on the same connection and supports transaction interleaving.
spring.jta.bitronix.datasource.enable-jdbc4-connection-test Set Connection.isValid() is called when acquiring a connection from the pool.
spring.jta.bitronix.datasource.ignore-recovery-failuresfalseSet recovery failures should be ignored.
spring.jta.bitronix.datasource.isolation-level The default isolation level for connections.
spring.jta.bitronix.datasource.local-auto-commit The default auto-commit mode for local transactions.
spring.jta.bitronix.datasource.login-timeout Timeout for establishing a database connection.(in second)
spring.jta.bitronix.datasource.max-idle-time60The time after which connections are cleaned up from the pool.(in second)
spring.jta.bitronix.datasource.max-pool-size10The maximum pool size. 0 denotes no limit.
spring.jta.bitronix.datasource.min-pool-size0The minimum pool size.
spring.jta.bitronix.datasource.prepared-statement-cache-size0The target size of the prepared statement cache. 0 disables the cache.
spring.jta.bitronix.datasource.share-transaction-connectionsfalseSet connections in the ACCESSIBLE state can be shared within the context of a transaction.
spring.jta.bitronix.datasource.test-query SQL query or statement used to validate a connection before returning it.
spring.jta.bitronix.datasource.two-pc-ordering-position1The position that this resource should take during two-phase commit (always first is Integer.MIN_VALUE, always last is Integer.MAX_VALUE).
spring.jta.bitronix.datasource.unique-namedataSourceThe unique name used to identify the resource during recovery.
spring.jta.bitronix.datasource.use-tm-jointrue Set TMJOIN should be used when starting XAResources.
spring.jta.bitronix.properties.allow-multiple-lrcfalseAllow multiple LRC resources to be enlisted into the same transaction.
spring.jta.bitronix.properties.asynchronous2-pcfalseEnable asynchronously execution of two phase commit.
spring.jta.bitronix.properties.background-recovery-interval-seconds60Interval at which to run the recovery process in the background.(in seconds)
spring.jta.bitronix.properties.current-node-only-recoverytrueRecover only the current node.
spring.jta.bitronix.properties.debug-zero-resource-transactionfalseLog the creation and commit call stacks of transactions executed without a single enlisted resource.
spring.jta.bitronix.properties.default-transaction-timeout60Default transaction timeout.(in second)
spring.jta.bitronix.properties.disable-jmxfalseEnable JMX support.
spring.jta.bitronix.properties.exception-analyzer Set the fully qualified name of the exception analyzer implementation to use.
spring.jta.bitronix.properties.filter-log-statusfalseEnable filtering of logs so that only mandatory logs are written.
spring.jta.bitronix.properties.force-batching-enabledtrueSet if disk forces are batched.
spring.jta.bitronix.properties.forced-write-enabledtrueSet if logs are forced to disk.
spring.jta.bitronix.properties.graceful-shutdown-interval60Maximum amount of seconds the TM will wait for transactions to get done before aborting them at shutdown time.
spring.jta.bitronix.properties.jndi-transaction-synchronization-registry-name JNDI name of the TransactionSynchronizationRegistry.
spring.jta.bitronix.properties.jndi-user-transaction-name JNDI name of the UserTransaction.
spring.jta.bitronix.properties.journaldiskName of the journal. Can be ‘disk’, ‘null’ or a class name.
spring.jta.bitronix.properties.log-part1-filenamebtm1.tlogName of the first fragment of the journal.
spring.jta.bitronix.properties.log-part2-filenamebtm2.tlogName of the second fragment of the journal.
spring.jta.bitronix.properties.max-log-size-in-mb2Maximum size in megabytes of the journal fragments.
spring.jta.bitronix.properties.resource-configuration-filename ResourceLoader configuration file name.
spring.jta.bitronix.properties.server-id ASCII ID that must uniquely identify this TM instance. Default to the machine’s IP address.
spring.jta.bitronix.properties.skip-corrupted-logsfalseSkip corrupted transactions log entries.
spring.jta.bitronix.properties.warn-about-zero-resource-transactiontrueLog a warning for transactions executed without a single enlisted resource.
BITRONIX Spring Boot Properties

References

https://docs.spring.io/spring-boot/docs/1.4.x/reference/html/common-application-properties.html

Happy Learning !!!

NARAYANA Spring Boot Properties

Narayana is a popular open source JTA transaction manager implementation supported by Red Hat. To use Narayana JTA in your Spring Boot application you can use You can use the narayana-spring-boot-starter starter to add the appropriate Narayana dependencies to your application.

NARAYANA pom.xml Dependencies

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-jta-narayana</artifactId>
</dependency>

Spring Boot automatically configures Narayana with default values and post-processes your beans to ensure that startup and shutdown ordering is correct.

NARAYANA Spring Boot Properties

Spring Boot load these properties in NarayanaProperties class with default values you can overwrite these values in your application application.properties/ application.yaml.

NameDefault ValueDescription
spring.jta.narayana.default-timeout60Transaction timeout.(in second)
spring.jta.narayana.expiry-scannerscom.arjuna.ats.internal. arjuna.recovery. ExpiredTransactionStatusManagerScannerComma-separated list of expiry scanners.
spring.jta.narayana.log-dir Transaction object store directory.
spring.jta.narayana.one-phase-committrueEnable one phase commit optimisation.
spring.jta.narayana.periodic-recovery-period120Interval in which periodic recovery scans are performed.(in second)
spring.jta.narayana.recovery-backoff-period10Back off period between first and second phases of the recovery scan.(in second)
spring.jta.narayana.recovery-db-pass Database password for recovery manager.
spring.jta.narayana.recovery-db-user Database username for recovery manager.
spring.jta.narayana.recovery-jms-pass JMS password for recovery manager.
spring.jta.narayana.recovery-jms-user JMS username for recovery manager.
spring.jta.narayana.recovery-modules Comma-separated recovery modules.
spring.jta.narayana.transaction-manager-id1Unique transaction manager id.
spring.jta.narayana.xa-resource-orphan-filters Comma-separated orphan filters.

By default, Narayana transaction logs written location is  transaction-logs directory in your application home directory (the directory in which your application jar file resides). You can customize the location of this directory by setting the narayana.log-dir or spring.jta.log-dir similar to that you can also customize the other properties.

References

Happy Learning !!!