小编Are*_*iak的帖子

Spring的事务上下文不会持久化数据

我知道我的问题是一个普遍的问题,但是我在这里检查了很多问题,检查了Spring文档,但我真的不知道我在做什么错。我的问题:我有一个使用JPA的Spring WebFlow项目(实现:OpenJPA + MySQL数据库)。我使用Spring ORM将EntityManager(通过@PersistenceContext注释)注入到我的简单RegisterDAO中。我已经配置了GlassFishs(正在使用的)连接池以使用MySQL,并且一切正常-我可以使用我的数据库,但是当我保留某些东西时-没有任何反应(数据未保留到数据库)。我知道问题出在我使用的事务上下文中。我阅读了Spring Transaction Management的文档,并按照本文档中的配置步骤进行操作。这是我的applicationContext.xml:

<?xml version="1.0" encoding="windows-1250"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:jee="http://www.springframework.org/schema/jee"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
       http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
       http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.0.xsd">

    <jee:jndi-lookup id="entityManagerFactory" jndi-name="myPersistenceUnit"/> 
    <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"/>

    <bean id="registerDaoImpl" class="umk.dumont.db.dao.RegisterDAO" />
    <bean id="registerModel" class="umk.dumont.models.RegisterFormModel">
        <property name="registerDAO" ref="registerDaoImpl" />
    </bean>


  <tx:advice id="txAdvice">
    <tx:attributes>
      <tx:method name="*" />
    </tx:attributes>
  </tx:advice> 

  <aop:config>
    <aop:pointcut id="registerModelOperation" expression="execution(* umk.dumont.models.RegisterFormModel.*(..))"/>
    <aop:advisor advice-ref="txAdvice" pointcut-ref="registerModelOperation"/>
  </aop:config>

  <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager" />


</beans>
Run Code Online (Sandbox Code Playgroud)

如您所见,我正在将RegisterDAO注入我的RegisterFormModel中,其中包含我的业务逻辑,用于验证注册表单数据并最终将用户添加到数据库中。验证工作正常,当我尝试添加新用户时出现问题。这是代码:

package umk.dumont.models;

...

public class RegisterFormModel implements Serializable {
    private String login;
    private …
Run Code Online (Sandbox Code Playgroud)

spring jpa transactional persist applicationcontext

5
推荐指数
1
解决办法
1万
查看次数

下载所有导入的XSD

我在XSD中使用gml(3.1.1)XSD作为我的应用程序.我想在3.1.1版本中下载所有gml XSD,例如zip文件.换句话说:base xsd就在这里,我想用zip文件中的所有导入或类似zip文件的方式下载这个XSD.有没有支持它的应用程序?我发现了这个下载器,但它对我不起作用(我认为这个应用程序不支持gml.xsd 3.1.1中发生的导入中的相对路径).有任何想法吗?

zip xsd download

5
推荐指数
1
解决办法
5187
查看次数

PostgreSQL自定义类型+Hibernate映射

我正在使用 PostgreSQL (9.1) 和 Hibernate (4.1.4)。我想将我的自定义 PostgreSQL 类型映射到 Hibernate 中的对象。

我在 PostgreSQL 中创建了这样的类型:

create type nill_int as (value int8, nill varchar(100));
Run Code Online (Sandbox Code Playgroud)

现在我想在 Hibernate 上映射这种类型:

package my;

import java.io.Serializable;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import org.apache.commons.lang.ObjectUtils;
import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.type.IntegerType;
import org.hibernate.type.StringType;
import org.hibernate.type.Type;
import org.hibernate.usertype.CompositeUserType;

public class PGNillableIntegerType implements CompositeUserType {

    @Override
    public String[] getPropertyNames() {
        return new String[] {"value","nill"};
    }

    @Override
    public Type[] getPropertyTypes() {
        return new Type[] {IntegerType.INSTANCE, StringType.INSTANCE};
    }

    @Override
    public Object getPropertyValue(Object component, …
Run Code Online (Sandbox Code Playgroud)

java mapping postgresql hibernate

5
推荐指数
1
解决办法
6072
查看次数

客户端新浏览器窗口中的GWT动态数据

我有GWT模块,我做了一些东西,我有搜索结果 - 无论以哪种形式.现在在搜索并点击例如"导出到HTML"按钮之后,我想创建新的html页面(例如通过创建简单的字符串来创建简单的字符串,其中仅包含搜索结果列表的列出结果)并打开它新的浏览器窗口.我知道有Window.open(...)方法,但我必须指定我没有的url.我想通过客户端创建这个新的html页面 - 没有服务器推断(我不想在服务器端创建一些资源,然后将url粘贴到此资源到客户端).有没有可能实现这个目标?如果没有选项,其他方法会让我满意,就是打开标准对话框进行保存,这样就可以将结果保存到html文件中.

谢谢你的帮助.

亲切的问候.

browser gwt window new-operator

2
推荐指数
1
解决办法
2068
查看次数

使用调色板从 TIFF 获取像素颜色索引

我有TIFF256 字节的调色板。在Java中我读这TIFFBufferedImage。这BufferedImageIndexColorModel. 当我遍历 中的像素时BufferedImage,我只能得到 RGB。我想编写方法,用于x,y从调色板中获取原始颜色索引BufferedImage(不是 RGB 颜色,只是来自TIFFs 调色板的原始索引)。我怎样才能做到这一点?

我知道我可以遍历 IndexColorModel 并检查 RBG 相等性,但是如果TIFF至少有 2 个具有相同颜色的索引(例如索引 0 - 黑色、132 - 黑色;假设像素 10x10 具有黑色[rgb=0,0,0]- 那么我不知道我应该采用哪个索引 - 它们具有相同的 RGB 值)。我也可以读取原始数据TIFF,然后计算字节数组中的像素位置,但我不想这样做 - 我想使用JAI.

有没有办法在有BufferedImageJAI没有外部库的情况下做到这一点?

谢谢

java tiff colors jai color-palette

2
推荐指数
1
解决办法
2203
查看次数