spring-data-jpa

UnknownHostException when trying to connect to heroku-postgres from local Springboot project with Spring JPA

岁酱吖の 提交于 2021-02-19 09:23:38
问题 I am trying to connect to heroku-postgres with Spring JPA when I am getting an unknownHostException. at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:292) ~[postgresql-42.2.5.jar:42.2.5] at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49) ~[postgresql-42.2.5.jar:42.2.5] at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:195) ~[postgresql-42.2.5.jar:42.2.5] at org.postgresql.Driver.makeConnection(Driver.java

UnknownHostException when trying to connect to heroku-postgres from local Springboot project with Spring JPA

﹥>﹥吖頭↗ 提交于 2021-02-19 09:20:19
问题 I am trying to connect to heroku-postgres with Spring JPA when I am getting an unknownHostException. at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:292) ~[postgresql-42.2.5.jar:42.2.5] at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49) ~[postgresql-42.2.5.jar:42.2.5] at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:195) ~[postgresql-42.2.5.jar:42.2.5] at org.postgresql.Driver.makeConnection(Driver.java

UnknownHostException when trying to connect to heroku-postgres from local Springboot project with Spring JPA

痞子三分冷 提交于 2021-02-19 09:19:20
问题 I am trying to connect to heroku-postgres with Spring JPA when I am getting an unknownHostException. at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:292) ~[postgresql-42.2.5.jar:42.2.5] at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49) ~[postgresql-42.2.5.jar:42.2.5] at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:195) ~[postgresql-42.2.5.jar:42.2.5] at org.postgresql.Driver.makeConnection(Driver.java

How to handle Spring Boot/ Spring Data projections with entity relationships (nested projection)

旧城冷巷雨未停 提交于 2021-02-19 09:04:24
问题 I'm trying to get nested projections working in Spring Boot. I have 2 entities, Parent and Child , wheras Parent has a unidirectional @OneToMany relationship to Child . Here are the classes: (using Lombok-Annotations) @Entity @Data @NoArgsConstructor public class Parent { @Id @GeneratedValue private long id; private String basic; private String detail; @OneToMany(fetch = FetchType.EAGER) private List<Child> children; public Parent(String basic, String detail, List<Child> children) { this

Add optional query parameter using spring data mongodb repository

試著忘記壹切 提交于 2021-02-19 06:07:20
问题 I want to add optional query parameters using spring data mongodb. Controller code: @RestController private final ActionService actionService; @RequestMapping(value = "/action/{id}", method = RequestMethod.GET) public ResponseEntity<List<Action>> getActionList(@PathVariable("id") long id, @RequestParam(value = "actionType", required = false) ActionType actionType, @RequestParam(value = " ", required = false) String[] params) { List<Action> actionList = actionService.getAction(id, actionType,

Can I mix both update and insert in saveAll from JpaRepository

限于喜欢 提交于 2021-02-19 04:43:06
问题 I am using Spring Boot and Spring Data JPA and Hibernate as the persistence provider. I have extended my Repository interface with JPARepository . I have a list of Entity Bean for a table. Some of them already exist and some of them not. I want to know what will happen when I call saveAll from my service layer and pass this List ? 回答1: If you look at the SimpleJpaRepository which is a common implementation of the CrudRepository you can see that it will simply invoke save for each of the

Spring config xml isn't valid after adding spring-data-jpa schema references

て烟熏妆下的殇ゞ 提交于 2021-02-19 03:34:09
问题 I have the following Exception while starting the spring context: java.lang.Exception: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.apache.catalina.LifecycleException: org.xml.sax.SAXParseException; systemId: http://www.springframework.org/schema/data/jpa/; lineNumber: 1; columnNumber: 55; White spaces are required between publicId and systemId. Before I added the spring-data-jpa to the spring config.xml everything worked fine.

Spring's AspectJ-mode caching versus AspectJ-mode transactions

空扰寡人 提交于 2021-02-18 11:44:07
问题 My question relates to Spring's AspectJ mode and especially how to enable it for: Transaction management Caching 1) I noticed that in order to enable the AspectJ mode for transaction management, I only had to do the following: @Configuration @EnableTransactionManagement(mode = AdviceMode.ASPECTJ) 2) Whereas in order to use AspectJ mode for caching it seems one has to: -Put the following jar into Tomcat's lib directory: org.springframework:spring-instrument-tomcat -Add the following line in

Spring data jpa - modifying query before execution

北战南征 提交于 2021-02-18 07:37:04
问题 I'm working on a project that keeps some access control information in the database. We're using that access control information to filter what the user can see. The filter that we're using is based on roles that the user has. We would like to use the Repository abstraction provided by Spring Data, but we would like to be able to adjust the generated queries before they are executed. Is there a way to attach a listener or an interceptor that will be called before a query is executed? That way

Spring JPA REST sort by nested property

淺唱寂寞╮ 提交于 2021-02-17 21:45:01
问题 I have entity Market and Event . Market entity has a column: @ManyToOne(fetch = FetchType.EAGER) private Event event; Next I have a repository: public interface MarketRepository extends PagingAndSortingRepository<Market, Long> { } and a projection: @Projection(name="expanded", types={Market.class}) public interface ExpandedMarket { public String getName(); public Event getEvent(); } using REST query /api/markets?projection=expanded&sort=name,asc I get successfully the list of markets with