- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在开发一个 Spring-MVC 应用程序,我在其中使用 @Scheduled 方法从数据库中删除旧信息(1 周前)。该方法被触发,我收到一封电子邮件,但数据库的内容没有被删除。
另外,我收到了 4 封电子邮件,我应该收到一封。有什么想法吗?
有问题的 DAO 代码:
@Repository
@Transactional
public class NotificationDAOImpl implements NotificationDAO{
private SessionFactory sessionFactory;
public void setSessionFactory(SessionFactory sf){
this.sessionFactory = sf;
}
private Session session;
public void setSession(Session session){this.session = session;}
@Override
@Scheduled(cron = "0 3 3 * * ?")
public void deleteNotificationsAutoMagically(){
Emails emails = new Emails();
emails.sendEmailForNotificationDelete();
session=this.sessionFactory.getCurrentSession();
long now = System.currentTimeMillis();
long nowMinus1Week = now - (1000 * 60 * 60 * 24 * 7);
Timestamp nowMinus1WeekAsTimeStamp = new Timestamp(nowMinus1Week);
Query query = session.createQuery("delete from NoteLock as nl where nl.timestamp<:limit");
query.setParameter("limit", nowMinus1WeekAsTimeStamp);
query.executeUpdate();
session.flush();
}
}
电子邮件代码:
public void sendEmailForNotificationDelete(){
final String from = "email@email.de";
final String emailPassword = "password";
Properties props = new Properties();
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.host", "mail.delink-ssl.net");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.port", "25");
Session session = Session.getDefaultInstance(props,
new Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(
from, emailPassword);
}
});
try {
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO, new InternetAddress("myemail@gmail.com"));
message.setSubject("Notifications were deleted");
String messageToSend = "Notifications were deleted";
message.setContent(messageToSend, "text/html;charset=UTF-8");
Transport.send(message);
}catch (Exception ignored){
}
}
任何帮助都会很好。多谢。
编辑
servlet-context.xml :
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task.xsd">
<context:annotation-config/>
<mvc:annotation-driven>
<mvc:argument-resolvers>
<beans:bean class="org.springframework.mobile.device.DeviceWebArgumentResolver"/>
</mvc:argument-resolvers>
</mvc:annotation-driven>
<mvc:interceptors>
<beans:bean class="org.springframework.mobile.device.DeviceResolverHandlerInterceptor"/>
</mvc:interceptors>
<mvc:default-servlet-handler/>
<resources mapping="/resources/" location="/resources/"/>
<beans:bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/views/"/>
<beans:property name="suffix" value=".jsp"/>
</beans:bean>
<beans:bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<beans:property name="driverClassName" value="org.postgresql.Driver"/>
<beans:property name="url"
value="jdbc:postgresql://localhost:5432/dbname"/>
<beans:property name="username" value="dbuser"/>
<beans:property name="password" value="dbpass"/>
<beans:property name="removeAbandoned" value="true"/>
<beans:property name="removeAbandonedTimeout" value="20"/>
<beans:property name="defaultAutoCommit" value="false"/>
</beans:bean>
<!-- Hibernate 4 SessionFactory Bean definition -->
<beans:bean id="hibernate4AnnotatedSessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<beans:property name="dataSource" ref="dataSource"/>
<beans:property name="annotatedClasses">
<beans:list>
<beans:value>com.journaldev.spring.model.Person</beans:value>
<beans:value>com.journaldev.spring.model.Notes</beans:value>
<beans:value>com.journaldev.spring.model.Canvas</beans:value>
<beans:value>com.journaldev.spring.model.Section</beans:value>
<beans:value>com.journaldev.spring.model.Attachment</beans:value>
<beans:value>com.journaldev.spring.model.GroupAccount</beans:value>
<beans:value>com.journaldev.spring.model.GroupMembers</beans:value>
<beans:value>com.journaldev.spring.model.GroupCanvas</beans:value>
<beans:value>com.journaldev.spring.model.GroupSection</beans:value>
<beans:value>com.journaldev.spring.model.GroupNotes</beans:value>
<beans:value>com.journaldev.spring.model.GroupAttachments
</beans:value>
<beans:value>com.journaldev.spring.model.Token</beans:value>
<beans:value>com.journaldev.spring.model.WaitingMembers
</beans:value>
<beans:value>com.journaldev.spring.model.NoteHistory</beans:value>
<beans:value>com.journaldev.spring.model.GroupNoteHistory
</beans:value>
<beans:value>com.journaldev.spring.model.Feedback</beans:value>
<beans:value>com.journaldev.spring.model.UnreadNotes</beans:value>
<beans:value>com.journaldev.spring.model.SessionState</beans:value>
<beans:value>com.journaldev.spring.model.FeatureRequest
</beans:value>
<beans:value>com.journaldev.spring.model.FeatureComment
</beans:value>
<beans:value>com.journaldev.spring.model.FeatureLike</beans:value>
<beans:value>com.journaldev.spring.model.OnlineUsers</beans:value>
<beans:value>com.journaldev.spring.model.NoteCount</beans:value>
<beans:value>com.journaldev.spring.model.NoteLock</beans:value>
<beans:value>com.journaldev.spring.model.ChatMessages</beans:value>
<beans:value>com.journaldev.spring.model.Conversation</beans:value>
<beans:value>com.journaldev.spring.model.Replies</beans:value>
<beans:value>com.journaldev.spring.model.Notification</beans:value>
<beans:value>com.journaldev.spring.model.Statistics</beans:value>
<beans:value>com.journaldev.spring.model.PrivateChannel</beans:value>
<!--<beans:value>com.journaldev.spring.model.GroupChannels</beans:value>-->
</beans:list>
</beans:property>
<beans:property name="hibernateProperties">
<beans:props>
<beans:prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQL9Dialect
</beans:prop>
<beans:prop key="hibernate.show_sql">false</beans:prop>
<beans:prop key="connection.pool_size">200</beans:prop>
<beans:prop key="c3p0.max_size">200</beans:prop>
<beans:prop key="c3p0.timeout">1000</beans:prop>
<beans:prop key="hibernate.jdbc.batch_size">1000</beans:prop>
<beans:prop key="hibernate.order_updates">true</beans:prop>
<beans:prop key="hibernate.hbm2ddl.auto">update</beans:prop>
</beans:props>
</beans:property>
</beans:bean>
<task:annotation-driven/>
<tx:annotation-driven transaction-manager="transactionManager"/>
<beans:bean id="transactionManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<beans:property name="sessionFactory" ref="hibernate4AnnotatedSessionFactory"/>
</beans:bean>
<!-- Person beans being here -->
<beans:bean id="personDAO" class="com.journaldev.spring.dao.PersonDAOImpl">
<beans:property name="sessionFactory"
ref="hibernate4AnnotatedSessionFactory"/>
</beans:bean>
<beans:bean id="personService"
class="com.journaldev.spring.service.PersonServiceImpl">
<beans:property name="personDAO" ref="personDAO"/>
</beans:bean>
<!-- <beans:bean id="bayeux" class="org.cometd.server.BayeuxServerImpl" init-method="start" destroy-method="stop">
<beans:property name="transports">
<beans:list>
<beans:bean id="jsonTransport" class="org.cometd.server.transport.JSONTransport">
<beans:constructor-arg ref="bayeux"/>
</beans:bean>
<beans:bean id="jsonpTransport" class="org.cometd.server.transport.JSONPTransport">
<beans:constructor-arg ref="bayeux"/>
</beans:bean>
</beans:list>
</beans:property>
</beans:bean>-->
<!-- Group Account beans begin here -->
<beans:bean id="groupAccountDAO"
class="com.journaldev.spring.dao.GroupAccountDAOImpl">
<beans:property name="sessionFactory"
ref="hibernate4AnnotatedSessionFactory"/>
</beans:bean>
<beans:bean id="groupAccountService"
class="com.journaldev.spring.service.GroupAccountServiceImpl">
<beans:property name="groupAccountDAO" ref="groupAccountDAO"/>
</beans:bean>
<!--Group Members bean begin here -->
<beans:bean id="groupMembersDAO"
class="com.journaldev.spring.dao.GroupMembersDAOImpl">
<beans:property name="sessionFactory"
ref="hibernate4AnnotatedSessionFactory"/>
</beans:bean>
<beans:bean id="groupMembersService"
class="com.journaldev.spring.service.GroupMembersServiceImpl">
<beans:property name="groupMembersDAO" ref="groupMembersDAO"/>
</beans:bean>
<!-- Notes bean begin here -->
<beans:bean id="notesDAO" class="com.journaldev.spring.dao.NotesDAOImpl">
<beans:property name="sessionFactory"
ref="hibernate4AnnotatedSessionFactory"/>
</beans:bean>
<beans:bean id="notesService"
class="com.journaldev.spring.service.NotesServiceImpl">
<beans:property name="notesDAO" ref="notesDAO"/>
</beans:bean>
<!--GroupNotes begin here -->
<beans:bean id="groupNotesDAO" class="com.journaldev.spring.dao.GroupNotesDAOImpl">
<beans:property name="sessionFactory"
ref="hibernate4AnnotatedSessionFactory"/>
</beans:bean>
<beans:bean id="groupNotesService"
class="com.journaldev.spring.service.GroupNotesServiceImpl">
<beans:property name="groupNotesDAO" ref="groupNotesDAO"/>
</beans:bean>
<!-- Canvas Beans begin here -->
<beans:bean id="canvasDAO" class="com.journaldev.spring.dao.CanvasDAOImpl">
<beans:property name="sessionFactory"
ref="hibernate4AnnotatedSessionFactory"/>
</beans:bean>
<beans:bean id="canvasService"
class="com.journaldev.spring.service.CanvasServiceImpl">
<beans:property name="canvasDAO" ref="canvasDAO"/>
</beans:bean>
<!--Group Canvas beans begin here -->
<beans:bean id="groupCanvasDAO"
class="com.journaldev.spring.dao.GroupCanvasDAOImpl">
<beans:property name="sessionFactory"
ref="hibernate4AnnotatedSessionFactory"/>
</beans:bean>
<beans:bean id="groupCanvasService"
class="com.journaldev.spring.service.GroupCanvasServiceImpl">
<beans:property name="groupCanvasDAO" ref="groupCanvasDAO"/>
</beans:bean>
<!-- Section beans begin here -->
<beans:bean id="sectionDAO" class="com.journaldev.spring.dao.SectionDAOImpl">
<beans:property name="sessionFactory"
ref="hibernate4AnnotatedSessionFactory"/>
</beans:bean>
<beans:bean id="sectionService"
class="com.journaldev.spring.service.SectionServiceImpl">
<beans:property name="sectionDAO" ref="sectionDAO"/>
</beans:bean>
<!-- Group Section beans begin here -->
<beans:bean id="groupSectionDAO"
class="com.journaldev.spring.dao.GroupSectionDAOImpl">
<beans:property name="sessionFactory"
ref="hibernate4AnnotatedSessionFactory"/>
</beans:bean>
<beans:bean id="groupSectionService"
class="com.journaldev.spring.service.GroupSectionServiceImpl">
<beans:property name="groupSectionDAO" ref="groupSectionDAO"/>
</beans:bean>
<beans:bean id="tokenDAO" class="com.journaldev.spring.dao.TokenDAOImpl">
<beans:property name="sessionFactory"
ref="hibernate4AnnotatedSessionFactory"/>
</beans:bean>
<beans:bean id="tokenService"
class="com.journaldev.spring.service.TokenServiceImpl">
<beans:property name="tokenDAO" ref="tokenDAO"/>
</beans:bean>
<beans:bean id="attachDAO" class="com.journaldev.spring.dao.AttachmentDAOImpl">
<beans:property name="sessionFactory"
ref="hibernate4AnnotatedSessionFactory"/>
</beans:bean>
<beans:bean id="attachService"
class="com.journaldev.spring.service.AttachmentServiceImpl">
<beans:property name="attachmentDAO" ref="attachDAO"/>
</beans:bean>
<beans:bean id="mattachDAO"
class="com.journaldev.spring.dao.GroupAttachmentsDAOImpl">
<beans:property name="sessionFactory"
ref="hibernate4AnnotatedSessionFactory"/>
</beans:bean>
<beans:bean id="mattachService"
class="com.journaldev.spring.service.GroupAttachmentsServiceImpl">
<beans:property name="groupAttachmentsDAO" ref="mattachDAO"/>
</beans:bean>
<beans:bean id="waitingDAO"
class="com.journaldev.spring.dao.WaitingMembersDAOImpl">
<beans:property name="sessionFactory"
ref="hibernate4AnnotatedSessionFactory"/>
</beans:bean>
<beans:bean id="waitingService"
class="com.journaldev.spring.service.WaitingMembersServiceImpl">
<beans:property name="waitingMembersDAO" ref="waitingDAO"/>
</beans:bean>
<beans:bean id="historyDAO"
class="com.journaldev.spring.dao.NoteHistoryDAOImpl">
<beans:property name="sessionFactory"
ref="hibernate4AnnotatedSessionFactory"/>
</beans:bean>
<beans:bean id="historyService"
class="com.journaldev.spring.service.NoteHistoryServiceImpl">
<beans:property name="noteHistoryDAO" ref="historyDAO"/>
</beans:bean>
<beans:bean id="mhistoryDAO"
class="com.journaldev.spring.dao.GroupNoteHistoryDAOImpl">
<beans:property name="sessionFactory"
ref="hibernate4AnnotatedSessionFactory"/>
</beans:bean>
<beans:bean id="mhistoryService"
class="com.journaldev.spring.service.GroupNoteHistoryServiceImpl">
<beans:property name="groupNoteHistoryDAO" ref="mhistoryDAO"/>
</beans:bean>
<beans:bean id="feedbackDAO" class="com.journaldev.spring.dao.FeedbackDAOImpl">
<beans:property name="sessionFactory"
ref="hibernate4AnnotatedSessionFactory"/>
</beans:bean>
<beans:bean id="feedbackService"
class="com.journaldev.spring.service.FeedbackServiceImpl">
<beans:property name="feedbackDAO" ref="feedbackDAO"/>
</beans:bean>
<beans:bean id="unreadDAO"
class="com.journaldev.spring.dao.UnreadNotesDAOImpl">
<beans:property name="sessionFactory"
ref="hibernate4AnnotatedSessionFactory"/>
</beans:bean>
<beans:bean id="unreadService"
class="com.journaldev.spring.service.UnreadNotesServiceImpl">
<beans:property name="unreadNotesDAO" ref="unreadDAO"/>
</beans:bean>
<beans:bean id="sessionStateDAO"
class="com.journaldev.spring.dao.SessionStateDAOImpl">
<beans:property name="sessionFactory"
ref="hibernate4AnnotatedSessionFactory"/>
</beans:bean>
<beans:bean id="sessionService"
class="com.journaldev.spring.service.SessionStateServiceImpl">
<beans:property name="sessionStateDAO" ref="sessionStateDAO"/>
</beans:bean>
<beans:bean id="featuresDAO"
class="com.journaldev.spring.dao.FeatureRequestDAOImpl">
<beans:property name="sessionFactory"
ref="hibernate4AnnotatedSessionFactory"/>
</beans:bean>
<beans:bean id="featuresService"
class="com.journaldev.spring.service.FeatureRequestServiceImpl">
<beans:property name="featureRequestDAO" ref="featuresDAO"/>
</beans:bean>
<beans:bean id="featureCommentDAO"
class="com.journaldev.spring.dao.FeatureCommentDAOImpl">
<beans:property name="sessionFactory"
ref="hibernate4AnnotatedSessionFactory"/>
</beans:bean>
<beans:bean id="featureCommentService"
class="com.journaldev.spring.service.FeatureCommentServiceImpl">
<beans:property name="featureCommentDAO" ref="featureCommentDAO"/>
</beans:bean>
<beans:bean id="featureLikeDAO"
class="com.journaldev.spring.dao.FeatureLikeDAOImpl">
<beans:property name="sessionFactory"
ref="hibernate4AnnotatedSessionFactory"/>
</beans:bean>
<beans:bean id="featureLikeService"
class="com.journaldev.spring.service.FeatureLikeServiceImpl">
<beans:property name="featureLikeDAO" ref="featureLikeDAO"/>
</beans:bean>
<beans:bean id="onlineUsersDAO"
class="com.journaldev.spring.dao.OnlineUsersDAOImpl">
<beans:property name="sessionFactory"
ref="hibernate4AnnotatedSessionFactory"/>
</beans:bean>
<beans:bean id="onlineUsersService"
class="com.journaldev.spring.service.OnlineUsersServiceImpl">
<beans:property name="onlineUsersDAO" ref="onlineUsersDAO"/>
</beans:bean>
<beans:bean id="noteCountDAO" class="com.journaldev.spring.dao.NoteCountDAOImpl">
<beans:property name="sessionFactory"
ref="hibernate4AnnotatedSessionFactory"/>
</beans:bean>
<beans:bean id="noteCountService"
class="com.journaldev.spring.service.NoteCountServiceImpl">
<beans:property name="noteCountDAO" ref="noteCountDAO"/>
</beans:bean>
<beans:bean id="noteLockDAO" class="com.journaldev.spring.dao.NoteLockDAOImpl">
<beans:property name="sessionFactory"
ref="hibernate4AnnotatedSessionFactory"/>
</beans:bean>
<beans:bean id="noteLockService"
class="com.journaldev.spring.service.NoteLockServiceImpl">
<beans:property name="noteLockDAO" ref="noteLockDAO"/>
</beans:bean>
<beans:bean id="chatDAO" class="com.journaldev.spring.dao.ChatMessagesDAOImpl">
<beans:property name="sessionFactory" ref="hibernate4AnnotatedSessionFactory"/>
</beans:bean>
<beans:bean id="chatService" class="com.journaldev.spring.service.ChatMessagesServiceImpl">
<beans:property name="chatDAO" ref="chatDAO"/>
</beans:bean>
<beans:bean id="conversationDAO" class="com.journaldev.spring.dao.ConversationDAOImpl">
<beans:property name="sessionFactory" ref="hibernate4AnnotatedSessionFactory"/>
</beans:bean>
<beans:bean id="conversationService" class="com.journaldev.spring.service.ConversationServiceImpl">
<beans:property name="conversationDAO" ref="conversationDAO"/>
</beans:bean>
<beans:bean id="repliesDAO" class="com.journaldev.spring.dao.RepliesDAOImpl">
<beans:property name="sessionFactory" ref="hibernate4AnnotatedSessionFactory"/>
</beans:bean>
<beans:bean id="repliesService" class="com.journaldev.spring.service.RepliesServiceImpl">
<beans:property name="repliesDAO" ref="repliesDAO"/>
</beans:bean>
<beans:bean id="notificationDAO" class="com.journaldev.spring.dao.NotificationDAOImpl">
<beans:property name="sessionFactory" ref="hibernate4AnnotatedSessionFactory"/>
</beans:bean>
<beans:bean id="notificationService" class="com.journaldev.spring.service.NotificationServiceImpl">
<beans:property name="notificationDAO" ref="notificationDAO"/>
</beans:bean>
<beans:bean id="statisticsDAO" class="com.journaldev.spring.dao.StatisticsDAOImpl">
<beans:property name="sessionFactory" ref="hibernate4AnnotatedSessionFactory"/>
</beans:bean>
<beans:bean id="statisticsService" class="com.journaldev.spring.service.StatisticsServiceImpl">
<beans:property name="statisticsDAO" ref="statisticsDAO"/>
</beans:bean>
<beans:bean id="privateChannelDAO" class="com.journaldev.spring.dao.PrivateChannelDAOImpl">
<beans:property name="sessionFactory" ref="hibernate4AnnotatedSessionFactory"/>
</beans:bean>
<beans:bean id="privateChannelService" class="com.journaldev.spring.service.PrivateChannelServiceImpl">
<beans:property name="privateChannelDAO" ref="privateChannelDAO"/>
</beans:bean>
<!-- <beans:bean id="groupChannelsDAO" class="com.journaldev.spring.dao.GroupChannelsDAOImpl">
<beans:property name="sessionFactory" ref="hibernate4AnnotatedSessionFactory"/>
</beans:bean>
<beans:bean id="groupChannelsService" class="com.journaldev.spring.service.GroupChannelsServiceImpl">
<beans:property name="groupChannelsDAO" ref="groupChannelsDAO"/>
</beans:bean>-->
<!--<beans:bean id="chatBean" class="com.journaldev.spring.chat.ChatServiceImpl"/>-->
<!--Login bean -->
<beans:bean id="LoginServiceImpl"
class="com.journaldev.spring.service.LoginServiceImpl"/>
<context:component-scan base-package="com.journaldev.spring"/>
<!-- locale -->
<beans:bean id="messageSource"
class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<beans:property name="basename" value="classpath:/locale/messages"/>
<beans:property name="defaultEncoding" value="UTF-8"/>
</beans:bean>
<context:property-placeholder location="classpath:application.properties"/>
<!-- default locale -->
<beans:bean id="localeResolver"
class="org.springframework.web.servlet.i18n.SessionLocaleResolver">
<beans:property name="defaultLocale" value="de"/>
</beans:bean>
<!-- Change locale via url. -->
<beans:bean id="localeChangeInterceptor"
class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
<beans:property name="paramName" value="lang"/>
</beans:bean>
<beans:bean id="handlerMapping"
class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping">
<beans:property name="interceptors">
<beans:list>
<beans:ref bean="localeChangeInterceptor"/>
</beans:list>
</beans:property>
</beans:bean>
<beans:bean class="com.journaldev.spring.service.DoNotTruncateMyUrls"/>
<beans:bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<beans:property name="maxUploadSize" value="52428800"/>
</beans:bean>
<beans:bean
class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
<beans:property name="messageConverters" ref="jsonMessageConverter"/>
</beans:bean>
<beans:bean id="jsonMessageConverter"
class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"/>
</beans:beans>
最佳答案
您的问题可能是 @Scheduled
和 @Transactional
如果为同一方法声明它们,则它们不能很好地协同工作。
尝试将计划的方法外部化到另一个 bean 中并使用您的 dao 的 Autowiring 实例(它具有事务方法)
关于java - Spring MVC, hibernate : Contents not deleted from database but method fired,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30391434/
什么是 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 公共
我是一名优秀的程序员,十分优秀!