- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 Maven
、Spring
、Hibernate
和 rest API
制作应用程序。以下是我的项目的层次结构。持久性模块已编译并可供业务模块使用,并且该业务模块可供端点模块使用。非常简单。
我使用 spring 注释
而不是 xml,这是我试图实现的流程。
基于Web的应用程序调用rest API,在API中调用一个函数,在该函数中调用businessLogic模块,并且在该函数中module 调用持久性模块,其中编写了所有 DAO 及其实现。 每个模块都有自己的配置文件。也非常简单。
根据我所了解到的,我们使用标签@EnableTransactionManagement
来让@Transaction
工作。@Transaction
标签可以用在函数上,并且该函数将被视为单个事务,无论其中调用了多少次插入、更新.
问题:问题很简单,当我启动 apache 时,甚至当我调用稍后调用持久性来保存对象的 API 时,我都没有遇到任何异常。没有数据插入数据库,日志文件中也没有打印异常。
记住层次结构,以下是项目中使用的文件。
EndpointConfiguration.java
@Configuration
@EnableTransactionManagement
@PropertySource(value = { "classpath:persistence-hibernate.properties" })
public class EndpointConfiguration{
@Autowired
public org.springframework.core.env.Environment environment;
@Bean(name = "sessionFactory")
public LocalSessionFactoryBean sessionFactory() {
LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean();
sessionFactory.setDataSource(dataSource());
sessionFactory.setPackagesToScan(new String[] { "com.product.persistence" });
sessionFactory.setHibernateProperties(hibernateProperties());
return sessionFactory;
}
@Bean(name = "dataSource")
public DataSource dataSource() {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName(environment.getRequiredProperty("jdbc.driverClassName"));
dataSource.setUrl(environment.getRequiredProperty("jdbc.url"));
dataSource.setUsername(environment.getRequiredProperty("jdbc.username"));
dataSource.setPassword(environment.getRequiredProperty("jdbc.password"));
return dataSource;
}
private Properties hibernateProperties() {
Properties properties = new Properties();
properties.put("hibernate.dialect", environment.getRequiredProperty("hibernate.dialect"));
properties.put("hibernate.show_sql", environment.getRequiredProperty("hibernate.show_sql"));
properties.put("hibernate.format_sql", environment.getRequiredProperty("hibernate.format_sql"));
return properties;
}
@Bean(name = "transactionManager")
public PlatformTransactionManager transactionManager() {
return new DataSourceTransactionManager(dataSource());
}
@Bean(name = "stakeHoldersBusinessLogic")
public IStakeHoldersBusinessLogic stakeHoldersBusinessLogic(){return new StakeHoldersBusinessLogicImpl(); }
@Bean(name = "daoFactoryCustom")
public DaoFactoryCustom daoFactoryCustom(){return new DaoFactoryCustomHbnImpl(); }
// some more beans
}
StakeHoldersEndpointImplRestController.java
@CrossOrigin(origins = "http://localhost:9090")
@RequestMapping(value = "/stakeHolders")
@RestController
public class StakeHoldersEndpointImplRestController implements IStakeHoldersEndpoint, InitializingBean {
@ResponseBody
@RequestMapping(value = "/createStakeHolder",
method = RequestMethod.POST,
headers = "Accept="+ MediaType.APPLICATION_JSON_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE)
public CreateStakeHolderResponse createStakeHolderEndpoint(@RequestBody CreateStakeHolderRequest request) {
LOG.trace("StakeHoldersEndpointImplRestController.createStakeHolder () - Start");
CreateStakeHolderResponse createStakeHolderResponse = new CreateStakeHolderResponse();
try{
createStakeHolderResponse = innerFunction(request);
}catch(Exception exception){
LOG.error("Exception Occurred : "+exception.getMessage());
}
LOG.trace("StakeHoldersEndpointImplRestController.createStakeHolder () - End");
return createStakeHolderResponse;
}
@Transactional
private CreateStakeHolderResponse innerFunction(CreateStakeHolderRequest request){
CreateStakeHolderResponse createStakeHolderResponse = new CreateStakeHolderResponse();
try {
createStakeHolderResponse = stakeHoldersBusinessLogic.createStakeHolderBusinessLogic(request);
}catch (Exception e){
LOG.error("Exception : ",e);
}
return createStakeHolderResponse;
}
BusinessLogicConfiguration.java
@Configuration
@EnableTransactionManagement
public class BusinessLogicConfiguration {
// some beans
}
StakeHoldersBusinessLogicImpl.java
public class StakeHoldersBusinessLogicImpl implements IStakeHoldersBusinessLogic, InitializingBean {
public CreateStakeHolderResponse createStakeHolderBusinessLogic(CreateStakeHolderRequest request) {
LOG.trace("StakeHoldersBusinessLogicImpl.createStakeHolderBusinessLogic () - Start");
CreateStakeHolderResponse createStakeHolderResponse = new CreateStakeHolderResponse(
IConstants.ERROR_CODE_BUSINESS_LOGIC_INITIATED_CODE , IConstants.ERROR_CODE_BUSINESS_LOGIC_INITIATED_STRING);
try{
//some logic to convert the request into stakeHolders, which is a Model bean mapped to a table
daoFactoryCustom.getStakeHoldersDAO().save(stakeHolders, 100L);
}catch(Exception exception){
LOG.error("Exception Occurred : ", exception);
}
LOG.trace("StakeHoldersBusinessLogicImpl.createStakeHolderBusinessLogic () - End");
return createStakeHolderResponse;
}
}
PersistenceConfiguration.java
@Configuration
@EnableTransactionManagement
public class PersistenceConfiguration {
// some beans
}
StakeHoldersDAOImpl.java
@Autowired(required = true)
SessionFactory sessionFactory;
public void save(T obj, Long creator) {
try{
getSession().save(obj);
}catch (Exception e){
LOG.error("Exception : ",e);
}
}
public final Session getSession() {
Session session;
try{
session = getSessionFactory().getCurrentSession();
}catch (HibernateException e){
session = sessionFactory.openSession();
}
return session;
}
我已经研究了一个多星期了,但找不到为什么会发生这种情况。此调用的日志跟踪如下。
18:09:14.653 [http-nio-8080-exec-2] DEBUG org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor : 193 - Read [class com.product.contract.requests.CreateStakeHolderRequest] as "application/json" with [org.springframework.http.converter.json.MappingJackson2HttpMessageConverter@30b367c7]
18:09:14.719 [http-nio-8080-exec-2] TRACE org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod : 134 - Invoking [StakeHoldersEndpointImplRestController.createStakeHolderEndpoint] method with arguments [com.product.contract.requests.CreateStakeHolderRequest@17b06234]
18:09:14.719 [http-nio-8080-exec-2] TRACE com.product.endpoint.controller.impl.StakeHoldersEndpointImplRestController : 47 - StakeHoldersEndpointImplRestController.createStakeHolder () - Start
18:09:14.720 [http-nio-8080-exec-2] TRACE com.product.businesslogic.impl.StakeHoldersBusinessLogicImpl : 100 - StakeHoldersBusinessLogicImpl.createStakeHolderBusinessLogic () - Start
18:09:14.743 [http-nio-8080-exec-2] TRACE org.hibernate.internal.SessionFactoryImpl$SessionBuilderImpl : 1201 - Opening Hibernate Session. tenant=null, owner=null
18:09:14.912 [http-nio-8080-exec-2] TRACE org.hibernate.service.internal.AbstractServiceRegistryImpl : 229 - Initializing service [role=org.hibernate.stat.spi.StatisticsImplementor]
18:09:14.921 [http-nio-8080-exec-2] DEBUG org.hibernate.stat.internal.StatisticsInitiator : 82 - Statistics initialized [enabled=false]
18:09:14.934 [http-nio-8080-exec-2] TRACE org.hibernate.internal.SessionImpl : 281 - Opened Session [e4202ec0-7fd9-4333-9db4-efefa24d7c53] at timestamp: 14952857548
18:09:14.938 [http-nio-8080-exec-2] TRACE org.hibernate.event.internal.DefaultSaveOrUpdateEventListener : 163 - Saving transient instance
18:09:14.949 [http-nio-8080-exec-2] DEBUG org.hibernate.SQL : 92 -
select
nextval ('pro5.entity_large')
18:09:14.950 [http-nio-8080-exec-2] DEBUG org.springframework.jdbc.datasource.DriverManagerDataSource : 142 - Creating new JDBC DriverManager Connection to [jdbc:postgresql://localhost:5432/postgres]
18:09:14.980 [http-nio-8080-exec-2] TRACE org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl : 55 - Registering statement [select nextval ('pro5.entity_large')]
18:09:15.086 [http-nio-8080-exec-2] TRACE org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl : 182 - Registering result set [org.postgresql.jdbc4.Jdbc4ResultSet@1d32dd3f]
18:09:15.092 [http-nio-8080-exec-2] DEBUG org.hibernate.id.enhanced.SequenceStructure : 101 - Sequence value obtained: 500046
18:09:15.093 [http-nio-8080-exec-2] TRACE org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl : 91 - Releasing result set [org.postgresql.jdbc4.Jdbc4ResultSet@1d32dd3f]
18:09:15.093 [http-nio-8080-exec-2] TRACE org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl : 132 - Closing result set [org.postgresql.jdbc4.Jdbc4ResultSet@1d32dd3f]
18:09:15.093 [http-nio-8080-exec-2] TRACE org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl : 68 - Releasing statement [select nextval ('pro5.entity_large')]
18:09:15.093 [http-nio-8080-exec-2] DEBUG org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl : 73 - HHH000387: ResultSet's statement was not registered
18:09:15.093 [http-nio-8080-exec-2] TRACE org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl : 148 - Closing prepared statement [select nextval ('pro5.entity_large')]
18:09:15.094 [http-nio-8080-exec-2] TRACE org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl : 263 - Starting afterQuery statement execution processing [AFTER_TRANSACTION]
18:09:15.095 [http-nio-8080-exec-2] DEBUG org.hibernate.event.internal.AbstractSaveEventListener : 118 - Generated identifier: 500046, using strategy: org.hibernate.id.enhanced.SequenceStyleGenerator
18:09:15.096 [http-nio-8080-exec-2] TRACE org.hibernate.event.internal.AbstractSaveEventListener : 157 - Saving [com.product.persistence.model.StakeHolders#500046]
18:09:15.116 [http-nio-8080-exec-2] TRACE org.hibernate.engine.spi.ActionQueue : 244 - Adding an EntityInsertAction for [com.product.persistence.model.StakeHolders] object
18:09:15.120 [http-nio-8080-exec-2] TRACE org.hibernate.engine.spi.IdentifierValue : 98 - ID unsaved-value strategy UNDEFINED
18:09:15.121 [http-nio-8080-exec-2] TRACE org.hibernate.persister.entity.AbstractEntityPersister : 1338 - Getting current persistent state for: [com.product.persistence.model.keyValuePair.CancellationReason#0]
18:09:15.122 [http-nio-8080-exec-2] DEBUG org.hibernate.SQL : 92 -
select
cancellati_.id_cancellation,
cancellati_.dat_last_update as dat_last4_1_,
cancellati_.id_customer_last_update as id_custo5_1_,
cancellati_.str_cancellation_reason as str_canc6_1_
from
pro5.cancellation_reason cancellati_
where
cancellati_.id_cancellation=?
18:09:15.123 [http-nio-8080-exec-2] TRACE org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl : 55 - Registering statement [select cancellati_.id_cancellation, cancellati_.dat_last_update as dat_last4_1_, cancellati_.id_customer_last_update as id_custo5_1_, cancellati_.str_cancellation_reason as str_canc6_1_ from pro5.cancellation_reason cancellati_ where cancellati_.id_cancellation=?]
18:09:15.127 [http-nio-8080-exec-2] TRACE org.hibernate.type.descriptor.sql.BasicBinder : 65 - binding parameter [1] as [INTEGER] - [0]
18:09:15.168 [http-nio-8080-exec-2] TRACE org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl : 182 - Registering result set [org.postgresql.jdbc4.Jdbc4ResultSet@1f3e3b2c]
18:09:15.171 [http-nio-8080-exec-2] TRACE org.hibernate.type.descriptor.sql.BasicExtractor : 51 - extracted value ([dat_last4_1_] : [TIMESTAMP]) - [null]
18:09:15.172 [http-nio-8080-exec-2] TRACE org.hibernate.type.descriptor.sql.BasicExtractor : 51 - extracted value ([id_custo5_1_] : [BIGINT]) - [null]
18:09:15.174 [http-nio-8080-exec-2] TRACE org.hibernate.type.descriptor.sql.BasicExtractor : 61 - extracted value ([str_canc6_1_] : [VARCHAR]) - [Fraud]
18:09:15.175 [http-nio-8080-exec-2] TRACE org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl : 91 - Releasing result set [org.postgresql.jdbc4.Jdbc4ResultSet@1f3e3b2c]
18:09:15.175 [http-nio-8080-exec-2] TRACE org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl : 132 - Closing result set [org.postgresql.jdbc4.Jdbc4ResultSet@1f3e3b2c]
18:09:15.175 [http-nio-8080-exec-2] TRACE org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl : 68 - Releasing statement [select cancellati_.id_cancellation, cancellati_.dat_last_update as dat_last4_1_, cancellati_.id_customer_last_update as id_custo5_1_, cancellati_.str_cancellation_reason as str_canc6_1_ from pro5.cancellation_reason cancellati_ where cancellati_.id_cancellation=0]
18:09:15.176 [http-nio-8080-exec-2] DEBUG org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl : 73 - HHH000387: ResultSet's statement was not registered
18:09:15.176 [http-nio-8080-exec-2] TRACE org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl : 148 - Closing prepared statement [select cancellati_.id_cancellation, cancellati_.dat_last_update as dat_last4_1_, cancellati_.id_customer_last_update as id_custo5_1_, cancellati_.str_cancellation_reason as str_canc6_1_ from pro5.cancellation_reason cancellati_ where cancellati_.id_cancellation=0]
18:09:15.176 [http-nio-8080-exec-2] TRACE org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl : 263 - Starting afterQuery statement execution processing [AFTER_TRANSACTION]
18:09:15.177 [http-nio-8080-exec-2] TRACE org.hibernate.engine.spi.IdentifierValue : 98 - ID unsaved-value strategy UNDEFINED
18:09:15.177 [http-nio-8080-exec-2] TRACE org.hibernate.persister.entity.AbstractEntityPersister : 1338 - Getting current persistent state for: [com.product.persistence.model.keyValuePair.Cities#0]
18:09:15.178 [http-nio-8080-exec-2] DEBUG org.hibernate.SQL : 92 -
select
cities_.id_city,
cities_.dat_last_update as dat_last4_2_,
cities_.id_customer_last_update as id_custo5_2_,
cities_.str_city as str_city6_2_
from
pro5.cities cities_
where
cities_.id_city=?
18:09:15.178 [http-nio-8080-exec-2] TRACE org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl : 55 - Registering statement [select cities_.id_city, cities_.dat_last_update as dat_last4_2_, cities_.id_customer_last_update as id_custo5_2_, cities_.str_city as str_city6_2_ from pro5.cities cities_ where cities_.id_city=?]
18:09:15.179 [http-nio-8080-exec-2] TRACE org.hibernate.type.descriptor.sql.BasicBinder : 65 - binding parameter [1] as [BIGINT] - [0]
18:09:15.199 [http-nio-8080-exec-2] TRACE org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl : 182 - Registering result set [org.postgresql.jdbc4.Jdbc4ResultSet@7b2493e9]
18:09:15.200 [http-nio-8080-exec-2] TRACE org.hibernate.type.descriptor.sql.BasicExtractor : 51 - extracted value ([dat_last4_2_] : [TIMESTAMP]) - [null]
18:09:15.200 [http-nio-8080-exec-2] TRACE org.hibernate.type.descriptor.sql.BasicExtractor : 51 - extracted value ([id_custo5_2_] : [BIGINT]) - [null]
18:09:15.201 [http-nio-8080-exec-2] TRACE org.hibernate.type.descriptor.sql.BasicExtractor : 61 - extracted value ([str_city6_2_] : [VARCHAR]) - [Lahore]
18:09:15.201 [http-nio-8080-exec-2] TRACE org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl : 91 - Releasing result set [org.postgresql.jdbc4.Jdbc4ResultSet@7b2493e9]
18:09:15.201 [http-nio-8080-exec-2] TRACE org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl : 132 - Closing result set [org.postgresql.jdbc4.Jdbc4ResultSet@7b2493e9]
18:09:15.202 [http-nio-8080-exec-2] TRACE org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl : 68 - Releasing statement [select cities_.id_city, cities_.dat_last_update as dat_last4_2_, cities_.id_customer_last_update as id_custo5_2_, cities_.str_city as str_city6_2_ from pro5.cities cities_ where cities_.id_city=0]
18:09:15.202 [http-nio-8080-exec-2] DEBUG org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl : 73 - HHH000387: ResultSet's statement was not registered
18:09:15.202 [http-nio-8080-exec-2] TRACE org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl : 148 - Closing prepared statement [select cities_.id_city, cities_.dat_last_update as dat_last4_2_, cities_.id_customer_last_update as id_custo5_2_, cities_.str_city as str_city6_2_ from pro5.cities cities_ where cities_.id_city=0]
18:09:15.202 [http-nio-8080-exec-2] TRACE org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl : 263 - Starting afterQuery statement execution processing [AFTER_TRANSACTION]
18:09:15.203 [http-nio-8080-exec-2] TRACE org.hibernate.engine.spi.IdentifierValue : 98 - ID unsaved-value strategy UNDEFINED
18:09:15.203 [http-nio-8080-exec-2] TRACE org.hibernate.persister.entity.AbstractEntityPersister : 1338 - Getting current persistent state for: [com.product.persistence.model.StakeHoldersType#10]
18:09:15.203 [http-nio-8080-exec-2] DEBUG org.hibernate.SQL : 92 -
select
stakeholde_.id_stake_holder_type,
stakeholde_.id_str_role as id_str_r3_25_,
stakeholde_.str_stake_holder_desc as str_stak2_25_
from
pro5.stake_holders_type stakeholde_
where
stakeholde_.id_stake_holder_type=?
18:09:15.204 [http-nio-8080-exec-2] TRACE org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl : 55 - Registering statement [select stakeholde_.id_stake_holder_type, stakeholde_.id_str_role as id_str_r3_25_, stakeholde_.str_stake_holder_desc as str_stak2_25_ from pro5.stake_holders_type stakeholde_ where stakeholde_.id_stake_holder_type=?]
18:09:15.205 [http-nio-8080-exec-2] TRACE org.hibernate.type.descriptor.sql.BasicBinder : 65 - binding parameter [1] as [BIGINT] - [10]
18:09:15.208 [http-nio-8080-exec-2] TRACE org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl : 182 - Registering result set [org.postgresql.jdbc4.Jdbc4ResultSet@3c215e9d]
18:09:15.209 [http-nio-8080-exec-2] TRACE org.hibernate.type.descriptor.sql.BasicExtractor : 51 - extracted value ([id_str_r3_25_] : [VARCHAR]) - [null]
18:09:15.210 [http-nio-8080-exec-2] TRACE org.hibernate.type.descriptor.sql.BasicExtractor : 61 - extracted value ([str_stak2_25_] : [VARCHAR]) - [Transport]
18:09:15.210 [http-nio-8080-exec-2] TRACE org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl : 91 - Releasing result set [org.postgresql.jdbc4.Jdbc4ResultSet@3c215e9d]
18:09:15.210 [http-nio-8080-exec-2] TRACE org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl : 132 - Closing result set [org.postgresql.jdbc4.Jdbc4ResultSet@3c215e9d]
18:09:15.211 [http-nio-8080-exec-2] TRACE org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl : 68 - Releasing statement [select stakeholde_.id_stake_holder_type, stakeholde_.id_str_role as id_str_r3_25_, stakeholde_.str_stake_holder_desc as str_stak2_25_ from pro5.stake_holders_type stakeholde_ where stakeholde_.id_stake_holder_type=10]
18:09:15.212 [http-nio-8080-exec-2] DEBUG org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl : 73 - HHH000387: ResultSet's statement was not registered
18:09:15.212 [http-nio-8080-exec-2] TRACE org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl : 148 - Closing prepared statement [select stakeholde_.id_stake_holder_type, stakeholde_.id_str_role as id_str_r3_25_, stakeholde_.str_stake_holder_desc as str_stak2_25_ from pro5.stake_holders_type stakeholde_ where stakeholde_.id_stake_holder_type=10]
18:09:15.212 [http-nio-8080-exec-2] TRACE org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl : 263 - Starting afterQuery statement execution processing [AFTER_TRANSACTION]
18:09:15.213 [http-nio-8080-exec-2] TRACE org.hibernate.engine.spi.ActionQueue : 257 - Adding insert with no non-nullable, transient entities: [EntityInsertAction[com.product.persistence.model.StakeHolders#500046]]
18:09:15.213 [http-nio-8080-exec-2] TRACE org.hibernate.engine.spi.ActionQueue : 280 - Adding resolved non-early insert action.
18:09:15.216 [http-nio-8080-exec-2] TRACE org.hibernate.engine.spi.IdentifierValue : 98 - ID unsaved-value strategy UNDEFINED
18:09:15.216 [http-nio-8080-exec-2] TRACE org.hibernate.engine.spi.IdentifierValue : 98 - ID unsaved-value strategy UNDEFINED
18:09:15.216 [http-nio-8080-exec-2] TRACE org.hibernate.engine.spi.IdentifierValue : 98 - ID unsaved-value strategy UNDEFINED
18:09:15.225 [http-nio-8080-exec-2] TRACE com.product.businesslogic.impl.StakeHoldersBusinessLogicImpl : 152 - StakeHoldersBusinessLogicImpl.createStakeHolderBusinessLogic () - End
18:09:15.225 [http-nio-8080-exec-2] TRACE com.product.endpoint.controller.impl.StakeHoldersEndpointImplRestController : 82 - StakeHoldersEndpointImplRestController.createStakeHolder () - End
18:09:15.226 [http-nio-8080-exec-2] TRACE org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod : 138 - Method [createStakeHolderEndpoint] returned [com.product.contract.responses.CreateStakeHolderResponse@6aac8e42]
18:09:15.301 [http-nio-8080-exec-2] DEBUG org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor : 226 - Written [com.product.contract.responses.CreateStakeHolderResponse@6aac8e42] as "application/json" using [org.springframework.http.converter.json.MappingJackson2HttpMessageConverter@30b367c7]
18:09:15.302 [http-nio-8080-exec-2] DEBUG org.springframework.web.servlet.DispatcherServlet : 1036 - Null ModelAndView returned to DispatcherServlet with name 'dispatcher': assuming HandlerAdapter completed request handling
18:09:15.302 [http-nio-8080-exec-2] TRACE org.springframework.web.servlet.DispatcherServlet : 1059 - Cleared thread-bound request context: org.apache.catalina.connector.RequestFacade@70e62c16
18:09:15.302 [http-nio-8080-exec-2] DEBUG org.springframework.web.servlet.DispatcherServlet : 997 - Successfully completed request
18:09:15.302 [http-nio-8080-exec-2] TRACE org.springframework.web.context.support.AnnotationConfigWebApplicationContext : 363 - Publishing event in WebApplicationContext for namespace 'dispatcher-servlet': ServletRequestHandledEvent: url=[/endpoint/stakeHolders/createStakeHolder]; client=[0:0:0:0:0:0:0:1]; method=[POST]; servlet=[dispatcher]; session=[null]; user=[null]; time=[807ms]; status=[OK]
18:09:15.302 [http-nio-8080-exec-2] TRACE org.springframework.web.context.support.AnnotationConfigWebApplicationContext : 363 - Publishing event in Root WebApplicationContext: ServletRequestHandledEvent: url=[/endpoint/stakeHolders/createStakeHolder]; client=[0:0:0:0:0:0:0:1]; method=[POST]; servlet=[dispatcher]; session=[null]; user=[null]; time=[807ms]; status=[OK]
我在这一切中做错了什么,任何帮助都会很棒。
谢谢
伊沙德·艾哈迈德。
最佳答案
首先,@Transactional
不适用于代理模式(默认)下的私有(private)方法。
其次,使用 @Transactional 注释 Controller 方法有点不寻常。通常您用它来注释服务类(如果您只有 DAO 而没有服务,则使用 DAO 类)。
所以我建议如下:
@Transactional
注释 StakeHoldersBusinessLogicImpl
(因为这似乎是您的服务)@Transactional
关于java - @EnableTransactionManagement 和 @Transaction 不适用于 Hibernate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44087481/
什么是 hibernate 和n- hibernate ?我可以在 Visual Studio 2008 中使用它进行 C# Web 应用程序开发吗?请给我建议...我是 asp.net Web 应用
我有一个不系统地发生的异常(exception)。 我试图通过在每次迭代中刷新和清理 session 来解决此问题,但没有成功。 [quartzScheduler_Worker-7] ERROR jd
使用 Hibernate 在数据库中存储 IP 地址的最佳类型是什么? 我虽然是 Byte[] 或 String,但有没有更好的方法,或者你用什么? @Column(name = "range_fr
我正在尝试制定一个公式来选择用户个人资料的用户友好名称。它选择名字 + ' ' + 姓氏 如果其中至少有一个不为空且不为空(包含非空白字符),否则选择 短名称 (条件相同),最后,如果 短名称 为空或
在hibernate中,是否可以将鉴别器作为一个实体?例如,如果我将 Department 作为基类,将 AdminDepartment 和 ProcessingDepartment 作为子类。 De
我只想从表中获取一些列值。因此,我已经使用投影来实现这一目标。该代码有效,但我认为它无效。 我的问题是当我使用ProjectionsList并将标准条件列表设置为ArrayList时-Bulletin
你好: 我对 hibernate 缓存缓存的内容感到困惑。 从文档中,我知道 hibernate 中有缓存类型。 一级 :交易级别。 似乎要被 session 持久化的实体被缓存在这里。 二级缓存 :
我遇到了一个情况: save或update hibernate 的目标表中的某些数据 在目标表上有一个触发器,该触发器将在目标表的insert或update操作之前执行 由 hibernate 将此记
我有一个名为 Master_Info_tbl 的表。它是一个查询表: 这是该表的代码: @Entity @Table(name="MASTER_INFO_T") public class Code
我想知道如何在 Hibernate 查询语言中使用日期文字。我在我的 JPA 项目中做了如下操作(作为 Eclipselink 提供者)并且它工作正常。 SELECT m FROM Me m WHER
@Entity public class Troop { @OneToMany(mappedBy="troop") public Set getSoldiers() { ...
我正在尝试使用 hibernate 查询删除表 'user_role' 中的所有行。但每次我都会出错。有人可以帮我吗。 DaoImpl @Override public void deleteAll(
不是将数据库操作分散在四个 (osgi) 包中,而是在那里做略有不同的事情。我想创建一个负责所有持久性问题的(简单的)OSGi 包。我觉得这并不像听起来那么简单,因为“每个包都有独特的类加载器”。 因
这就是我使用生成器的方式: private Integer id; 我看到的行为是: 创建第一个对象 hibernate 分配 id = 1 删除该对象 关闭服务
对象级别的实体和值类型有什么区别。我知道实体将有一个 id 但值不会,但为什么我们需要不同的方法来映射实体与值类型? 这样做是为了让hibernate可以对值类型应用任何优化吗? 最佳答案 一个实体已
我正在使用 HibernateTemplate.findByCriteria 方法进行一些查询。现在我想在标准上创建一些 SQL 限制,比如 criteria.add(Restrictions.sql
所以我有以下代码: Query query = session.createQuery("from Weather"); List list = query.list();
如何使用Hibernate映射具有多个实体的 View ? 问候, 混沌 最佳答案 请参见Hibernate文档中第5.1.3节“类”,紧接在“Id”节之前: There is no differen
据我所知,Hibernate 有两种类型的实现 JPA的实现(2)(@Entity,@Table注解) 扩展到旧的(传统的) hibernate (没有 JPA),使用 HSQL 查询,没有注释 如果
我需要一个将条目存储为键值对的集合(因此我可以通过键查找值),但我需要一个允许多个值使用 hibernate 共享同一个键的集合 最佳答案 一个键具有多个值的映射称为多映射 - 在 Apache 公共
我是一名优秀的程序员,十分优秀!