我的entityManager persist()从序列获取id并将其放到我的Image对象中,但Image对象本身没有显示在数据库中.EntityManager.flush()给出了一个错误,所以我不能这样提交.这是我的代码.
@Repository
public class ImageDaoImpl extends BaseDao implements ImageDao {
@PersistenceContext
protected EntityManager entityManager;
@Override
@Transactional
public void create(Image image) {
JpaTemplate jpaTemplate = getJpaTemplate(entityManager);
jpaTemplate.persist(image);
}
Run Code Online (Sandbox Code Playgroud)
@Repository
public class BaseDao {
private JpaTemplate jpaTemplate;
public JpaTemplate getJpaTemplate(EntityManager entityManager){
if(jpaTemplate == null)
jpaTemplate = new JpaTemplate(entityManager);
return jpaTemplate;
}
Run Code Online (Sandbox Code Playgroud)
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
p:dataSource-ref="dataSource">
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql" value="true" />
<property name="generateDdl" value="true" />
<property name="databasePlatform" value="org.hibernate.dialect.PostgreSQLDialect" />
</bean>
</property>
<property name="persistenceUnitName" value="sample"></property>
</bean>
<!-- DataSource …
Run Code Online (Sandbox Code Playgroud) 我正试图让西里尔语成为拉丁文,所以我可以把它们放在网址中.我使用icu4j transliterator,但它仍然会给出这样奇怪的字符:Vil'ândimaa.它应该更像viljandimaa.当我复制那个网址时,这些字母会变成%..某些东西没用.
有谁知道怎么用icu4j把西里尔语变成az?
UPDATE
不能回答自己,但发现这个问题非常有用:将符号,口音字母转换为英文字母
数据:
values date
14 1.1.2010
20 1.1.2010
10 2.1.2010
7 4.1.2010
...
Run Code Online (Sandbox Code Playgroud)
关于2010年1月的样本查询应该得到31行.每天一个.值得加入.现在我可以用31个查询做到这一点,但我希望这可以用一个.可能吗?
结果:
1. 34
2. 10
3. 0
4. 7
...
Run Code Online (Sandbox Code Playgroud) 我有需要密钥库的java代码,我有privateKey.pem和bank.cer文件.私钥是为银行和bank.cer签署一个值来验证银行的响应.我找不到将它们放入密钥库的方法,因此我的代码可以工作.
可以用keytool完成吗?
我似乎找不到解决一个简单问题的方法.我需要写一个xsd文件.
我想要像这样的xml文件:
<info lang="someLang">Some long text not longer than 3000</info>
Run Code Online (Sandbox Code Playgroud)
我无法获得maxLength限制.现在我试过这样的事,但这不对.
<element minOccurs="1" maxOccurs="1" name="Info">
<complexType>
<simpleContent>
<restriction base="string">
<maxLength value="3000" />
<attribute name="lang" type="language"/>
</restriction>
</simpleContent>
</complexType>
</element>
Run Code Online (Sandbox Code Playgroud) <bean
class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
<property name="mappedHandlers">
<set>
<ref bean="exceptionController" />
</set>
</property>
<property name="defaultErrorView" value="tiles/content/error" />
</bean>
Run Code Online (Sandbox Code Playgroud)
我正在尝试向控制器发送异常,以便我可以创建重定向.如果我注释掉mappedHandlers部分,则会显示错误图块,但它只是一个图块.其余的瓷砖正常加载.我需要在控制器中进行重定向,这样我才能显示错误页面,而不仅仅是错误图块.
我找不到足够的信息或示例如何在exceptionController中调用异常方法.