- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
Spring Boot JPA Postgres。
实体没有被保存,而日志中没有明显的异常。
package com.demo.kmd.models;
import java.util.List;
import com.plaid.client.response.TransactionsGetResponse.Transaction.Location;
import com.plaid.client.response.TransactionsGetResponse.Transaction.PaymentMeta;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name = "spendschema.transaction")
public class TransactionInfo {
@Id
@GeneratedValue
private Long genId; //generated id locally in database .
private String accountId;
private Double amount;
private String isoCurrencyCode;
private String unofficialCurrencyCode;
private String categoryId;
private String date;
private String name;
private String originalDescription;
private Boolean pending;
private String pendingTransactionId;
private String transactionId;
private String transactionType;
private String accountOwner;
public String getTransactionId() {
return transactionId;
}
public String getAccountId() {
return accountId;
}
public Boolean getPending() {
return pending;
}
public String getPendingTransactionId() {
return pendingTransactionId;
}
public String getTransactionType() {
return transactionType;
}
public String getDate() {
return date;
}
public String getName() {
return name;
}
public Double getAmount() {
return amount;
}
}
package com.demo.kmd.repository;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Component;
import com.demo.kmd.models.TransactionInfo;
@Component
public interface TransactionJpaRepository extends CrudRepository<TransactionInfo, Long>{
}
package com.demo.kmd.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.demo.kmd.models.TransactionInfo;
import com.demo.kmd.repository.TransactionJpaRepository;
@Service
public class PersistanceService {
@Autowired
TransactionJpaRepository transactionJpaRepository;
public TransactionInfo insert(TransactionInfo transactionInfo) {
return transactionJpaRepository.save(transactionInfo);
}
}
package com.demo.controller;
import com.demo.kmd.models.TransactionInfo;
....
import retrofit2.Response;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.demo.kmd.service.PersistanceService;
import static org.springframework.web.bind.annotation.RequestMethod.*;
@Controller
public class TestController {
@Autowired
PersistanceService persistanceService;
@RequestMapping(value="/test1", method=GET, produces=MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody ResponseEntity getTransactions3() throws Exception {
System.out.print("test hit");
TransactionInfo transactionInfo = new TransactionInfo();
transactionInfo.setAccountId("ACCOUNTID1234");
transactionInfo.setAmount(4000.12);
transactionInfo = persistanceService.insert(transactionInfo);
return ResponseEntity.ok(transactionInfo);
}
logging.level.root=DEBUG
logging.level.org.hibernate=DEBUG
spring.datasource.url=jdbc:postgresql://192.168.0.23:5432/spenddb
spring.datasource.username= spenduser
spring.datasource.password= ***
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto = update`
select * from spendschema.transaction
**No result `**
019-12-07 10:02:49.406 DEBUG 3628 --- [nio-8080-exec-7] o.j.s.OpenEntityManagerInViewInterceptor : Opening JPA EntityManager in OpenEntityManagerInViewInterceptor
test hit2019-12-07 10:02:49.408 DEBUG 3628 --- [nio-8080-exec-7] o.s.orm.jpa.JpaTransactionManager : Found thread-bound EntityManager [org.hibernate.jpa.internal.EntityManagerImpl@7fa03c3f] for JPA transaction
2019-12-07 10:02:49.408 DEBUG 3628 --- [nio-8080-exec-7] o.s.orm.jpa.JpaTransactionManager : Creating new transaction with name [org.springframework.data.jpa.repository.support.SimpleJpaRepository.save]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT; ''
2019-12-07 10:02:49.408 DEBUG 3628 --- [nio-8080-exec-7] o.h.e.t.internal.TransactionImpl : begin
2019-12-07 10:02:49.416 DEBUG 3628 --- [nio-8080-exec-7] o.s.orm.jpa.JpaTransactionManager : Exposing JPA transaction as JDBC transaction [org.springframework.orm.jpa.vendor.HibernateJpaDialect$HibernateConnectionHandle@7b9fb713]
2019-12-07 10:02:49.418 DEBUG 3628 --- [nio-8080-exec-7] org.hibernate.SQL : select nextval ('hibernate_sequence')
Hibernate: select nextval ('hibernate_sequence')
2019-12-07 10:02:49.423 DEBUG 3628 --- [nio-8080-exec-7] org.hibernate.id.SequenceGenerator : Sequence identifier generated: BasicHolder[java.lang.Long[16]]
2019-12-07 10:02:49.424 DEBUG 3628 --- [nio-8080-exec-7] o.h.r.j.i.ResourceRegistryStandardImpl : HHH000387: ResultSet's statement was not registered
2019-12-07 10:02:49.424 DEBUG 3628 --- [nio-8080-exec-7] o.h.e.i.AbstractSaveEventListener : Generated identifier: 16, using strategy: org.hibernate.id.SequenceGenerator
2019-12-07 10:02:49.425 DEBUG 3628 --- [nio-8080-exec-7] o.s.orm.jpa.JpaTransactionManager : Initiating transaction commit
2019-12-07 10:02:49.425 DEBUG 3628 --- [nio-8080-exec-7] o.s.orm.jpa.JpaTransactionManager : Committing JPA transaction on EntityManager [org.hibernate.jpa.internal.EntityManagerImpl@7fa03c3f]
2019-12-07 10:02:49.425 DEBUG 3628 --- [nio-8080-exec-7] o.h.e.t.internal.TransactionImpl : committing
2019-12-07 10:02:49.425 DEBUG 3628 --- [nio-8080-exec-7] o.h.e.i.AbstractFlushingEventListener : Processing flush-time cascades
2019-12-07 10:02:49.425 DEBUG 3628 --- [nio-8080-exec-7] o.h.e.i.AbstractFlushingEventListener : Dirty checking collections
2019-12-07 10:02:49.426 DEBUG 3628 --- [nio-8080-exec-7] o.h.e.i.AbstractFlushingEventListener : Flushed: 1 insertions, 0 updates, 0 deletions to 1 objects
2019-12-07 10:02:49.426 DEBUG 3628 --- [nio-8080-exec-7] o.h.e.i.AbstractFlushingEventListener : Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
2019-12-07 10:02:49.426 DEBUG 3628 --- [nio-8080-exec-7] o.hibernate.internal.util.EntityPrinter : Listing entities:
2019-12-07 10:02:49.426 DEBUG 3628 --- [nio-8080-exec-7] o.hibernate.internal.util.EntityPrinter : com.demo.kmd.models.TransactionInfo{date=null, amount=4000.12, pending=null, accountOwner=null, transactionId=null, genId=16, transactionType=null, accountId=ACCOUNTID1234, name=null, unofficialCurrencyCode=null, pendingTransactionId=null, isoCurrencyCode=null, categoryId=null, originalDescription=null}
2019-12-07 10:02:49.427 DEBUG 3628 --- [nio-8080-exec-7] org.hibernate.SQL : insert into spendschema_transaction (account_id, account_owner, amount, category_id, date, iso_currency_code, name, original_description, pending, pending_transaction_id, transaction_id, transaction_type, unofficial_currency_code, gen_id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into spendschema_transaction (account_id, account_owner, amount, category_id, date, iso_currency_code, name, original_description, pending, pending_transaction_id, transaction_id, transaction_type, unofficial_currency_code, gen_id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
2019-12-07 10:02:49.437 DEBUG 3628 --- [nio-8080-exec-7] o.s.orm.jpa.JpaTransactionManager : Not closing pre-bound JPA EntityManager after transaction
2019-12-07 10:02:49.440 DEBUG 3628 --- [nio-8080-exec-7] o.s.w.s.m.m.a.HttpEntityMethodProcessor : Written [com.demo.kmd.models.TransactionInfo@3e9d3604] as "application/json" using [org.springframework.http.converter.json.MappingJackson2HttpMessageConverter@129ecd4a]
2019-12-07 10:02:49.441 DEBUG 3628 --- [nio-8080-exec-7] o.s.web.servlet.DispatcherServlet : Null ModelAndView returned to DispatcherServlet with name 'dispatcherServlet': assuming HandlerAdapter completed request handling
2019-12-07 10:02:49.441 DEBUG 3628 --- [nio-8080-exec-7] o.j.s.OpenEntityManagerInViewInterceptor : Closing JPA EntityManager in OpenEntityManagerInViewInterceptor
2019-12-07 10:02:49.441 DEBUG 3628 --- [nio-8080-exec-7] o.s.orm.jpa.EntityManagerFactoryUtils : Closing JPA EntityManager
2019-12-07 10:02:49.441 DEBUG 3628 --- [nio-8080-exec-7] o.h.e.jdbc.internal.JdbcCoordinatorImpl : HHH000420: Closing un-released batch
2019-12-07 10:02:49.442 DEBUG 3628 --- [nio-8080-exec-7] o.s.web.servlet.DispatcherServlet : Successfully completed request
2019-12-07 10:02:49.442 DEBUG 3628 --- [nio-8080-exec-7] o.s.b.w.f.OrderedRequestContextFilter : Cleared thread-bound request context: org.apache.catalina.connector.RequestFacade@9687fb6
2019-12-07 10:02:49.443 DEBUG 3628 --- [nio-8080-exec-7] o.a.tomcat.util.net.SocketWrapperBase : Socket: [org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper@7167dc63:org.apache.tomcat.util.net.NioChannel@1ba33e7e:java.nio.channels.SocketChannel[connected local=/0:0:0:0:0:0:0:1:8080 remote=/0:0:0:0:0:0:0:1:53851]], Read from buffer: [0]
2019-12-07 10:02:49.443 DEBUG 3628 --- [nio-8080-exec-7] o.apache.coyote.http11.Http11Processor : Socket: [org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper@7167dc63:org.apache.tomcat.util.net.NioChannel@1ba33e7e:java.nio.channels.SocketChannel[connected local=/0:0:0:0:0:0:0:1:8080 remote=/0:0:0:0:0:0:0:1:53851]], Status in: [OPEN_READ], State out: [OPEN]
2019-12-07 10:03:14.811 DEBUG 3628 --- [nio-8080-exec-8] o.a.tomcat.util.net.SocketWrapperBase : Socket: [org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper@1f62c78:org.apache.tomcat.util.net.NioChannel@30a5cb21:java.nio.channels.SocketChannel[connected local=/0:0:0:0:0:0:0:1:8080 remote=/0:0:0:0:0:0:0:1:53852]], Read from buffer: [0]
2019-12-07 10:03:14.812 DEBUG 3628 --- [nio-8080-exec-8] o.apache.coyote.http11.Http11Processor : Error parsing HTTP request header
java.io.EOFException: null
at org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.fillReadBuffer(NioEndpoint.java:1250) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
at org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.read(NioEndpoint.java:1190) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
at org.apache.coyote.http11.Http11InputBuffer.fill(Http11InputBuffer.java:717) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
at org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:366) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:687) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-embed-core-8.5.23.jar:8.5.23]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868) [tomcat-embed-core-8.5.23.jar:8.5.23]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459) [tomcat-embed-core-8.5.23.jar:8.5.23]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-8.5.23.jar:8.5.23]
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [na:1.8.0_181]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [na:1.8.0_181]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-8.5.23.jar:8.5.23]
at java.lang.Thread.run(Unknown Source) [na:1.8.0_181]
2019-12-07 10:03:14.813 DEBUG 3628 --- [nio-8080-exec-8] o.apache.coyote.http11.Http11Processor : Socket: [org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper@1f62c78:org.apache.tomcat.util.net.NioChannel@30a5cb21:java.nio.channels.SocketChannel[connected local=/0:0:0:0:0:0:0:1:8080 remote=/0:0:0:0:0:0:0:1:53852]], Status in: [OPEN_READ], State out: [CLOSED]
最佳答案
问题是您正在使用 new 关键字创建 TransactionInfo transactionInfo = new TransactionInfo();
而它应该是 @Autowired,因为它是 Spring 驱动的服务 bean。
关于java - Spring boot JPA Postgres enrity 未保存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59228933/
我有以下情况要解决,但无法正常工作(尝试了Hibernate和EclipseLink): Table_1: Column_A is Primary Key ... some other
我是 JPA 的新手,但必须在该技术中实现我的项目 我想做的是通过 CriteriaQuery 构建一些数据库查询,但不知道如何将参数列表传递给下面的代码: CriteriaBuilder qb =
我是 JPA 新手,注意到可以通过使用 @Version 注释实体中的字段来使用乐观锁定。我只是好奇,如果之前不存在,持久性提供程序是否会创建一个隐式版本字段。例如网站objectdb状态: "Whe
我有一个 JPA 查询 @Query(value = "SELECT SUM(total_price) FROM ... WHERE ...", nativeQuery = true) 当有匹配的记录
JPA 是否会尝试在已经持久(和非分离)的实体上级联持久化? 为了清楚起见,这是我的情况:我想保留一个新用户: public void addUser(){ //User is an enti
显然,OpenJPA。我也看到提到过 EclipseLink 和 Hibernate,但是在功能上有显着差异吗? 最佳答案 大多数差异来自提供者对 OSGi 的感知程度。例如,您可能需要自己将 Hib
我想将 JPA 用于 micronaut。为此,我使用 io.micronaut.data:micronaut-data-hibernate-jpa:1.0.0.M1 库。每当我运行应用程序并点击端点
我正准备为我的应用实现后端,现在我正在投影数据层。我期待着 Spring 。 最佳答案 Spring Data JPA 不是 JPA 实现。它提供了将数据访问层构建到底层 JPA 顶部的方法。您是否应
假设我有一个表 Item,其中包含一个名为 user_id 的列和一个表 User 以及另一个名为 Superuser 的列: CREATE TABLE Item(id int, user_id in
JPA 2.1 规范说: The entity class must not be final. No methods or persistent instance variables of the
我正在从事一个具有一些不寻常实体关系的项目,我在使用 JPA 时遇到了问题。有两个相关对象;用户,让我们称另一个 X。用户与 X 具有一对多和两个一对一的关系。它基本上看起来像这样 [用户实体] @O
我说的是 JavaEE 中的 JPA。在我读过的一本书中谈到: EntityManager em; em.find(Employee.class, id); “这是实体管理器在数据库中查找实例所需的所
我有 JPA 支持的 Vaadin 应用程序。此应用程序中的组件绑定(bind)到 bean 属性(通过独立的 EL 实现)。一些组件绑定(bind)到外部对象(或其字段),由@OneToOne、@O
是否可以使表中的外键唯一?假设我有实体 A 和 B。 答: @Entity class A extends Serializable { @Id private long id; @OneToOne
我在使用 JPA 时遇到了一点问题。考虑这种情况: 表 A (id_a) | 表 B (id_b, id_a) 我需要的是这样的查询: Select a.*, c.quantity from A as
我有一个由 JPA 管理的实体类,我有一个实体需要在其属性中记录更改。 JPA 是否提供任何方法来处理这种需求? 最佳答案 如果您使用 Hibernate 作为 JPA 提供程序,请查看 Hibern
我想实现以下架构: Table A: a_id (other columns) Table B: b_id (other columns) Table C: c_id (other columns)
我有一个愚蠢的问题。如果能做到的话那就太好了,但我并没有屏住呼吸。 我需要链接到我的 JPA 实体的表中的单个列作为所述 JPA 实体中的集合。有什么方法可以让我单独取回与该实体相关的列,而不必取回整
我有一个 Open JPA 实体,它成功连接了多对多关系。现在我成功地获取了整个表,但我实际上只想要该表中的 ID。我计划稍后调用数据库来重建我需要的实体(根据我的程序流程)。我只需要 ID(或该表中
这是我的一个实体的复合主键。 public class GroupMembershipPK implements Serializable{ private static final long
我是一名优秀的程序员,十分优秀!