How I can delete a row form entity while using ManytoOne? - spring

I have two Entities: Order and items.
Each order has many item.
public class Order extends BaseEntity {
#Id
#Column(name="order_id", updatable = false)
private String order_id = UUID.randomUUID().toString();
#Column(name="order_number", updatable = false)
private Integer orderNumber;
#Column(name="date_created")
private String dateCreated;
#Column(name="expected_money_range")
private Integer expectedMoneyRange;
#Column(name="total_amount")
private Double totalAmount;
#ManyToOne()
#JoinColumn(name = "customer_id", nullable = true)
private Customer customer;
#OneToMany(fetch = FetchType.EAGER,cascade = CascadeType.ALL,mappedBy = "order")
#Fetch(FetchMode.SELECT)
private List<Item> item = new ArrayList<>();
}
And
public class Item extends BaseEntity {
#Id
#Column(name = "item_id", updatable = false)
private String Item_Id = UUID.randomUUID().toString();
#Column(name = "description")
private String Description;
#Column(name = "images")
private byte[] Images;
#ManyToOne()
#JoinColumn(name = "order_id", nullable = true)
private Order order;
}
But when I want to delete an Order, nothing happens.
I am using orderRepository.deleteById(orderId).
I tried also to add orphan removal but nothing happens. Can anyone please help?
Log:
2021-12-08 14:51:18,575 [15957096] INFO - ij.compiler.impl.CompileDriver - COMPILATION STARTED (BUILD PROCESS)
2021-12-08 14:51:18,589 [15957110] INFO - j.compiler.server.BuildManager - Using preloaded build process to compile /Users/marwa/Documents/ESDT Projects/deliverytest
2021-12-08 14:51:18,894 [15957415] INFO - lij.compiler.impl.CompilerUtil - COMPILATION FINISHED (BUILD PROCESS); Errors: 0; warnings: 0 took 331 ms: 0 min 0sec
2021-12-08 14:51:18,909 [15957430] INFO - s.CompilerReferenceServiceBase - backward reference index reader is opened
2021-12-08 14:51:18,979 [15957500] INFO - ij.execution.JavaExecutionUtil - Agent jars were copied to /Users/marwa/Library/Caches/JetBrains/IdeaIC2021.2/captureAgent
2021-12-08 14:51:19,520 [15958041] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stdout]: Build process started. Classpath: /Applications/IntelliJ IDEA CE.app/Contents/plugins/java/lib/jps-launcher.jar
2021-12-08 14:51:21,867 [15960388] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: WARNING: An illegal reflective access operation has occurred
2021-12-08 14:51:21,867 [15960388] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: WARNING: Illegal reflective access by com.intellij.util.ReflectionUtil (file:/Applications/IntelliJ%20IDEA%20CE.app/Contents/lib/util.jar) to method java.util.ResourceBundle.setParent(java.util.ResourceBundle)
2021-12-08 14:51:21,867 [15960388] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: WARNING: Please consider reporting this to the maintainers of com.intellij.util.ReflectionUtil
2021-12-08 14:51:21,867 [15960388] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
2021-12-08 14:51:21,867 [15960388] INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: WARNING: All illegal access operations will be denied in a future release
2021-12-08 14:52:36,515 [16035036] DEBUG - BackendServerFileEditorManager - Opening host editor for /Users/marwa/Documents/ESDT Projects/deliverytest/src/main/java/com/esdt/deliverytest/Order/Service/OrderServiceImpl.java
2021-12-08 14:53:43,524 [16102045] DEBUG - BackendServerFileEditorManager - Opening host editor for /Users/marwa/Documents/ESDT Projects/deliverytest/src/main/java/com/esdt/deliverytest/Order/Service/OrderServiceImpl.java

Related

Why doesn't Hibernate L2 cache turn on?

I do not understand why my Hibernate L2 cache doesn't work.
I have Spring Boot application with following configuration
jpa:
database-platform: org.hibernate.dialect.PostgreSQL10Dialect
show-sql: true
properties:
hibernate:
format_sql: true
cache :
use_second_level_cache: true
region :
factory_class: org.hibernate.cache.ehcache.EhCacheRegionFactory
use_query_cache : true
provider_class : net.sf.ehcache.hibernate.SingletonEhCacheProvider
generate_statistics : true
use_structured_entries : true
Following entity mush be cached
#Entity
#Table(name = "employees", schema = "security", catalog = "")
//#SQLDelete(sql = "update security.employees set deleted_ts = current_timestamp where id=?")
//#Where(clause = "deleted_ts is null")
#Cacheable
#org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
class Employee : BaseUuidEntity(), CompanyRelated,UserRelated{
#ManyToOne
#JoinColumn(name = "user_id", nullable = false)
var user: User? = null
#ManyToOne
#JoinColumn(name = "company_id")
var company: Company? = null
#Column(name = "owner")
var owner: Boolean? = null
#ManyToOne
#JoinColumn(name = "role_id")
var role: Role? = null
#ElementCollection
#CollectionTable(
name = "employee_project",
schema = "security",
joinColumns = [JoinColumn(name = "employee_id")]
)
#Column(name = "project_id")
var projectIds: MutableSet<UUID>? = null
override fun getObjUserId(): UUID? {
return user?.id
}
override fun getObjCompanyId(): UUID? {
return company?.id
}
}
But in logs in second page request I have repeated query:
Hibernate:
select
employee0_.id as id1_37_,
employee0_.created_by as created_2_37_,
employee0_.created_ts as created_3_37_,
employee0_.deleted_by as deleted_4_37_,
employee0_.deleted_ts as deleted_5_37_,
employee0_.updated_by as updated_6_37_,
employee0_.updated_ts as updated_7_37_,
employee0_.company_id as company_9_37_,
employee0_.owner as owner8_37_,
employee0_.role_id as role_id10_37_,
employee0_.user_id as user_id11_37_
from
security.employees employee0_
left outer join
security.employee_project projectids1_
on employee0_.id=projectids1_.employee_id
where
projectids1_.project_id=?
The queries are called this way
...
employeeRepository.findByProjectIds(project.id!!)
...
interface EmployeeRepository : JpaSpecRepository<Employee> {
...
#PostFilter("hasObjectPermission(filterObject, 'Employee', 'View')")
fun findByProjectIds(projectId: UUID): MutableList<Employee>
...
You can see full log here https://gist.github.com/iva-nova-e-katerina/37ef0b489cc94d693c6e7640ff01f507
Please teach me how to turn on Hibernate L2 cache?
Probably a bit more TRACE level logs make situation clean:
2022-07-31 10:41:01,085 TRACE [http-nio-8080-exec-8] org.hibernate.type.descriptor.sql.BasicBinder: binding parameter [1] as [OTHER] - [dcc5ff7b-ec8b-45d7-be0f-bcf6a55f1206]
2022-07-31 10:41:01,086 DEBUG [http-nio-8080-exec-8] org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler: Filtering with expression: hasObjectPermission(filterObject, 'Employee', 'View')
2022-07-31 10:41:01,087 DEBUG [http-nio-8080-exec-8] org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler: Filtering collection with 0 elements
2022-07-31 10:41:01,087 DEBUG [http-nio-8080-exec-8] org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler: Retaining elements: []
2022-07-31 10:41:01,088 DEBUG [http-nio-8080-exec-8] org.hibernate.engine.jdbc.spi.SqlStatementLogger:
select
employee0_.id as id1_37_,
employee0_.created_by as created_2_37_,

Q: Transactional Code why does this work so well?

Hello my professionals I have a simple question here that I would like to beg to solve this..
this is an Entity of Member
#Entity
#Getter
#Builder
#NoArgsConstructor(access = AccessLevel.PROTECTED)
#AllArgsConstructor
/*#ToString(of = {"id", "username", "age"})*/
public class Member {
#Id
/*#GeneratedValue(strategy = GenerationType.IDENTITY)*/
#Column(name = "member_id")
private Long id;
private String username;
private int age;
#OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "member")
private List<Team> teams;
#OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "member")
private List<Coach> coachs;
}
And this is an Entity of Coach
#Entity
#AllArgsConstructor
#Getter
#Builder
#Setter
#NoArgsConstructor
#ToString(of = {"id","name","career"})
public class Coach {
#Id
#GeneratedValue(strategy = GenerationType.IDENTITY)
#Column(name= "coach_id")
private Long id;
#Column
private String name;
#Column
private String career;
#ManyToOne(fetch = FetchType.LAZY,cascade = ALL)
#JoinColumn(name = "member_id")
private Member member;
#OneToOne(fetch = FetchType.LAZY,cascade = ALL)
#JoinColumn(name = "team_id")
private Team team;
}
and This is Controller Code
#GetMapping("/member")
public void createUser(){
Member m = memberService.createMember();
Coach c = m.getCoachs().get(0);
log.info(c.getName());
}
and This is Service Code
private final MemberRepository memberRepository;
#Transactional
public Member createMember(){
return memberRepository.findMemberById(3L);
}
and the last this is RepositoryCode
Member findMemberById(Long id);
So my question is that when i printed out Coach's name at the controller on console
it printed out so well.
but what I know the Transaction is over from the service So the persistence container is closed that means coach name can't be imported cause it's LAZY loading and persistence container is closed but it was printed out well
I want to know the reason why ...
here are the console results Thanks !!
[2022-01-10 23:27:46.835] [http-nio-9000-exec-2] [] INFO o.a.c.c.C.[.[.[/] - Initializing Spring DispatcherServlet 'dispatcherServlet'
[2022-01-10 23:27:46.835] [http-nio-9000-exec-2] [] INFO o.s.w.s.DispatcherServlet - Initializing Servlet 'dispatcherServlet'
[2022-01-10 23:27:46.855] [http-nio-9000-exec-2] [] INFO o.s.w.s.DispatcherServlet - Completed initialization in 19 ms
Hibernate:
/* select
generatedAlias0
from
Member as generatedAlias0
where
generatedAlias0.id=:param0 */ select
member0_.member_id as member_i1_1_,
member0_.age as age2_1_,
member0_.username as username3_1_
from
member member0_
where
member0_.member_id=?
[2022-01-10 23:27:47.007] [http-nio-9000-exec-2] [4c0222d3] INFO p6spy - #1641824867007 | took 15ms | statement | connection 1| url jdbc:mariadb://patrick-lab.cjeq2ffynlc2.ap-northeast-2.rds.amazonaws.com:3306/patricklab?characterEncoding=UTF-8&serverTimezone=UTC
/* select generatedAlias0 from Member as generatedAlias0 where generatedAlias0.id=:param0 */ select member0_.member_id as member_i1_1_, member0_.age as age2_1_, member0_.username as username3_1_ from member member0_ where member0_.member_id=?
/* select generatedAlias0 from Member as generatedAlias0 where generatedAlias0.id=:param0 */ select member0_.member_id as member_i1_1_, member0_.age as age2_1_, member0_.username as username3_1_ from member member0_ where member0_.member_id=3;
[2022-01-10 23:27:47.170] [http-nio-9000-exec-2] [4c0222d3] INFO p6spy - #1641824867170 | took 12ms | commit | connection 1| url jdbc:mariadb://patrick-lab.cjeq2ffynlc2.ap-northeast-2.rds.amazonaws.com:3306/patricklab?characterEncoding=UTF-8&serverTimezone=UTC
;
Hibernate:
select
coachs0_.member_id as member_i4_0_0_,
coachs0_.coach_id as coach_id1_0_0_,
coachs0_.coach_id as coach_id1_0_1_,
coachs0_.career as career2_0_1_,
coachs0_.member_id as member_i4_0_1_,
coachs0_.name as name3_0_1_,
coachs0_.team_id as team_id5_0_1_
from
coach coachs0_
where
coachs0_.member_id=?
[2022-01-10 23:27:47.200] [http-nio-9000-exec-2] [4c0222d3] INFO p6spy - #1641824867200 | took 12ms | statement | connection 1| url jdbc:mariadb://patrick-lab.cjeq2ffynlc2.ap-northeast-2.rds.amazonaws.com:3306/patricklab?characterEncoding=UTF-8&serverTimezone=UTC
select coachs0_.member_id as member_i4_0_0_, coachs0_.coach_id as coach_id1_0_0_, coachs0_.coach_id as coach_id1_0_1_, coachs0_.career as career2_0_1_, coachs0_.member_id as member_i4_0_1_, coachs0_.name as name3_0_1_, coachs0_.team_id as team_id5_0_1_ from coach coachs0_ where coachs0_.member_id=?
select coachs0_.member_id as member_i4_0_0_, coachs0_.coach_id as coach_id1_0_0_, coachs0_.coach_id as coach_id1_0_1_, coachs0_.career as career2_0_1_, coachs0_.member_id as member_i4_0_1_, coachs0_.name as name3_0_1_, coachs0_.team_id as team_id5_0_1_ from coach coachs0_ where coachs0_.member_id=3;
[2022-01-10 23:27:47.213] [http-nio-9000-exec-2] [4c0222d3] INFO m.p.l.m.c.MemberController - Coach1
I believe it is because you are using the spring-boot default setting which the spring.jpa.open-in-view is set to true .
This property enables OpenSessionInView pattern which you can simply think that a transaction will be opened automatically for you at the very first beginning when processing any HTTP request (e.g. in the Servlet Filter etc). Because of this , a transaction is actually already open before your service method executes and it is still active after your service method completes. Hence you will not experience any LazyInitializationException even after you access non-initialized properties outside the service method as the transaction is still active.
There is a strong debate about whether or not spring-boot should enable it by default in the past . You can refer this for more details if you are interested. I personally would recommend to turn it off.

Spring Boot Data JPA #Version Returns 0 on Create but is 1 in the database

I have a project using spring-boot-starter-data-jpa version 2.2.6.RELEASE with an aOracle 12c database. I have a version field in my entity annotated with javax.persistance #Version annotation. When I save an entity for the first time, the query returns a version of 0, but in the database I can see it has been set to 1. It is like the transaction ends before the updated version is returned.
I've tried with both CrudRepository's save() method and JpaRepository's saveAndFlush() method, but neither work. Note, subsequent updates to the entity do return the correct version. This problem only happens when creating a new record.
When I use the EntityManager directly with saveAndRefresh(), it works as it should, but I'd like to avoid doing that if possible. Can someone please help?
UPDATE
Here are the entity, repository and service classes. I've tried with JpaRepository and saveAndFlush() too, but the outcome is the same:
#Getter
#Setter
#NoArgsConstructor
#ToString
#EqualsAndHashCode
#Entity
#Table(name = "TD_INCIDENTS")
public class Incident {
#Id
#GeneratedValue(strategy = GenerationType.IDENTITY)
#Column(name = "INCIDENT_ID", nullable = false)
private Long incidentId;
#Column(name = "INCIDENT_STATUS")
private Integer statusCode;
#Version
#Column(name = "INCIDENT_VER_NUM")
private Long version;
}
#Repository
public interface IncidentRepository extends CrudRepository<Incident, Long> {
}
#Service
public class IncidentServiceImpl implements IncidentService {
private final IncidentRepository incidentRepository;
public IncidentServiceImpl(IncidentRepository incidentRepository)
{
this.caseRepository = caseRepository;
}
#Override
#Transactional(rollbackFor = Exception.class)
public Incident createIncident(String statusCode) {
var newIncident = new Incident();
newIncident.setStatusCode(1);
// the line below returns an incident with version 0, but in db it is 1
return incidentRepository.save(newIncident);
}
#Override
#Transactional
public Incident getIncident(Long incidentId) {
return incidentRepository.findById(incidentId);
}
#Override
#Transactional(rollbackFor = Exception.class)
public Incident updateIncident(Long incidentId, Integer statusCode, Long version) {
var incident = this.getIncident(incidentId);
if (incident != null) {
if (incident.getVersion().equals(version)) {
incident.setStatusCode(statusCode);
// the line below returns an incident with an updated version the same as in the db
return incidentRepository.save(incident);
}else {
throw new OptimisticLockException("Expected versions do not match");
}
}
return null;
}
}
UPDATE
Here is the log output from the insert:
2020-07-26 13:54:09.675 DEBUG 9140 --- [nio-8080-exec-1] org.hibernate.SQL :
insert
into
td_incidents
(incident_id, incident_status, incident_ver_num)
values
(default, ?, ?)
2020-07-26 13:54:09.701 TRACE 9140 --- [nio-8080-exec-1] o.h.type.descriptor.sql.BasicBinder : binding parameter [1] as [INTEGER] - [1]
2020-07-26 13:54:09.703 TRACE 9140 --- [nio-8080-exec-1] o.h.type.descriptor.sql.BasicBinder : binding parameter [2] as [BIGINT] - [0]
And here is the log output from the update. Note, I'm sending the version number as 1 in the request, as that's what it is in the db. If I send it as 0, the application will throw the OptimisticLockException
2020-07-26 13:56:29.346 DEBUG 9140 --- [nio-8080-exec-3] org.hibernate.SQL :
select
incident0_.incident_id as incident_id1_0_0_,
incident0_.incident_status as incident_status_2_0_0_,
incident0_.incident_ver_num as incident_ver_num_3_0_0_
from
td_incidents incident0_
where
incident0_.incident_id_id=?
2020-07-26 13:56:29.347 TRACE 9140 --- [nio-8080-exec-3] o.h.type.descriptor.sql.BasicBinder : binding parameter [1] as [BIGINT] - [1044]
2020-07-26 13:56:29.401 DEBUG 9140 --- [nio-8080-exec-3] org.hibernate.SQL :
update
td_incidents
set
incident_status=?,
incident_ver_num=?
where
incident_id=?
and incident_ver_num=?
2020-07-26 13:56:29.402 TRACE 9140 --- [nio-8080-exec-3] o.h.type.descriptor.sql.BasicBinder : binding parameter [1] as [INTEGER] - [2]
2020-07-26 13:56:29.402 TRACE 9140 --- [nio-8080-exec-3] o.h.type.descriptor.sql.BasicBinder : binding parameter [2] as [BIGINT] - [2]
2020-07-26 13:56:29.403 TRACE 9140 --- [nio-8080-exec-3] o.h.type.descriptor.sql.BasicBinder : binding parameter [3] as [BIGINT] - [1044]
2020-07-26 13:56:29.404 TRACE 9140 --- [nio-8080-exec-3] o.h.type.descriptor.sql.BasicBinder : binding parameter [4] as [BIGINT] - [1]
INCIDENT_VER_NUM field should not have autoincrement column but you seems to have an autoincrecment column as it is managed and incremented by JPA
If you can't remove autocrement, try this option and it could work. But I have used this option so far other fields that are generated by database not for #Version
#Version
#Column(name = "INCIDENT_VER_NUM", insertable = false, updatable = false)
#org.hibernate.annotations.Generated(value = GenerationTime.ALWAYS)
private Long version;

EntityNotFoundException on OneToOne Mapping, even though entity exists

I have two classes:
public class Account {
#Id
#GeneratedValue(strategy = GenerationType.AUTO)
#Column(name = "accountId")
private Long id;
#OneToOne(optional = true)
#JoinColumn(name = "informationId")
private Information information;
}
public class Information {
#Id
#GeneratedValue(strategy = GenerationType.AUTO)
#Column(name = "informationId")
private Long id;
#OneToOne(mappedBy = "information", cascade = CascadeType.ALL, optional = true)
private Account account;
}
When I make a call that retrieves an Account, I get this exception:
WARN o.h.e.loading.internal.LoadContexts - HHH000100: Fail-safe cleanup (collections) : org.hibernate.engine.loading.internal.CollectionLoadContext#2ecc21a
WARN o.h.e.l.i.CollectionLoadContext - HHH000160: On CollectionLoadContext#cleanup, localLoadingCollectionKeys contained [1] entries
WARN Unable to find Information with id 114; nested exception is javax.persistence.EntityNotFoundException: Unable to find Information with id 114
However, the database shows that there is an Information object with informationId 114, and an Account with a informationId foreign key of 114.
How come I am getting this exception?
EDIT
This is the call that causes the exception:
List<Following> following = followingService.findFollowingByUserId(userId);
In followingService, this is just a call to the dao. A Following object has a User object, and the User owns an Account. The following object populates just fine if I remove the Account mapping
Can you post complete code where this entity is being persisted and fetched?
This information is not sufficient to answer this query.
Could it be that you have a table with 1 entity and the other table with 0?
For me it seems like this:
Account
ID | Name | InformationID
-------------------------
1 | Acc | 114
-------------------------
Information
ID | Name | Account
-------------------
-------------------

Spring, application.properties for creation of ElephantSQL tables

I try to do deploying (I use pivotal.io).
Before deploying I try to create tables of my DB.
On pivotal.io I create the test database (ElephantSQL). This new DB have:
Shared high performance cluster
20 MB data
4 concurrent connections
I use Spring and this describe my DB in application properties. This works if I create DB on my localhost.`
spring.datasource.url=jdbc:postgresql://stampy.db.elephantsql.com:5432/iyraxwqa
spring.datasource.username=iyraxwqa
spring.datasource.password=*************************
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
spring.jpa.hibernate.ddl-auto=create
spring.jpa.database=POSTGRESQL
spring.datasource.platform=postgres
spring.jpa.show-sql=false`
When I Run my application I see this ERROR:
2017-05-14 12:53:38.810 ERROR 4880 --- [ main] o.a.tomcat.jdbc.pool.ConnectionPool : Unable to create initial connections of pool.
org.postgresql.util.PSQLException: FATAL: too many connections for role "iyraxwqa"
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2455) ~[postgresql-9.4.1212.jre7.jar:9.4.1212.jre7]
at org.postgresql.core.v3.QueryExecutorImpl.readStartupMessages(QueryExecutorImpl.java:2586) ~[postgresql-9.4.1212.jre7.jar:9.4.1212.jre7]
at org.postgresql.core.v3.QueryExecutorImpl.<init>(QueryExecutorImpl.java:113) ~[postgresql-9.4.1212.jre7.jar:9.4.1212.jre7]
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:222) ~[postgresql-9.4.1212.jre7.jar:9.4.1212.jre7]
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:51) ~[postgresql-9.4.1212.jre7.jar:9.4.1212.jre7]
at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:215) ~[postgresql-9.4.1212.jre7.jar:9.4.1212.jre7]
at org.postgresql.Driver.makeConnection(Driver.java:404) ~[postgresql-9.4.1212.jre7.jar:9.4.1212.jre7]
at org.postgresql.Driver.connect(Driver.java:272) ~[postgresql-9.4.1212.jre7.jar:9.4.1212.jre7]
at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:310) ~[tomcat-jdbc-8.5.6.jar:na]
at org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:203) ~[tomcat-jdbc-8.5.6.jar:na]
at org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:718) [tomcat-jdbc-8.5.6.jar:na]
I include hibernate h3p0 and add this code:
spring.jpa.properties.hibernate.c3p0.min_size = 1
spring.jpa.properties.hibernate.c3p0.max_size = 2
spring.jpa.properties.hibernate.c3p0.timeout = 300
But I see the same error.
If I try to create manually all is working, but I have a lot of tables and half year ago I created tables with spring and hibernate
One of my tables:
#Entity
#Table(name = "INTERIOR", schema = "public")
public class InteriorModel extends AllFinishProductModel {
#Column(name = "PHOTO")
private String photo;
#Column(name = "PHOTO01")
private String photo01;
#Column(name = "PHOTO02")
private String photo02;
#Id
#Column(name = "ID")
#GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id;
#Column
private String name;
#Column(name = "DESCRIPTION")
private String description;
#Column(name = "COLOR")
private String color;
#Column(name = "QUANTITY")
private Double quantity;
#Column(name = "PRICE")
private BigDecimal price;
// getters and setters....
Somebody know, where my mistake?
I have the same problem, I think you are using the Free plan(Tiny Turtle). I think the problem is the max number of connection that PosgreSql(elephantsql server) support, to know the max limit connection you can execute the follow sql script in your ElephantSql browser:
select * from pg_roles where rolname='iyraxwqa'
it display your role configuration in postgresql and you can see the column 'rolconnlimit' to know the max number of connection supported
I don't understand why, but when I delete c3p0 and started to use tomcat everything works. This code is working:
spring.datasource.tomcat.max-wait=1000
spring.datasource.tomcat.max-active=3
spring.datasource.tomcat.test-on-borrow=true

Resources