小编dem*_*101的帖子

域对象字符串字段自动修剪

从Grails 2.2.3更新到Grails 2.3.5(groovy 2.0.8-> 2.1.9)后,我发现奇怪的行为Domain对象:

class Element {
  String name
  String title
  static constraints = {
    title nullable: true
  }
}
Run Code Online (Sandbox Code Playgroud)

在创建过程中,String字段自动修剪,空字符串替换为null

def e = new Element(name:'', title:'  sgg gg ')
assert e.name==null
assert e.title=='sgg gg'
Run Code Online (Sandbox Code Playgroud)

我在Grails&groovy的更新日志中找不到这个超级功能.我怎么能禁用它?

grails grails-orm

9
推荐指数
1
解决办法
1698
查看次数

Hibernate 继承和二级缓存代理

简单的应用程序在以下实体结构中工作错误

@Entity(name="some_table")
@Inheritance(strategy= InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn( name="TYPE", discriminatorType=DiscriminatorType.STRING )
abstract class EntityBase {
    @Id
    @GeneratedValue(strategy= GenerationType.AUTO)
    @Column
    private int id;
}

@Entity
@DiscriminatorValue("EntityA")
@Cacheable
class EntityA extends EntityBase {
    @Column
    private int aColumn;
...
}

@Entity
@DiscriminatorValue("EntityB")
@Cacheable
class EntityB extends EntityBase {
    @Column
    private int bColumn;
...
}

@Entity(name="holder_table")
@Cacheable
class HolderEntity {
    @Id
    @GeneratedValue(strategy= GenerationType.AUTO)
    @Column
    private int id;

    @ManyToOne(fetch=FetchType.LAZY)
    EntityBase holdedEntity;

    ...
}
Run Code Online (Sandbox Code Playgroud)

对于首次加载或没有缓存,一切正常

从缓存加载 HolderEntity 实例后,holdedEntity 字段由 EntityBase 类型(抽象类)的对象初始化。

伪代码:

def a = HolderEntity.get(1)
assert a.holdedEntity.class!=EntityBase //ok …
Run Code Online (Sandbox Code Playgroud)

java orm caching hibernate hibernate-mapping

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

带有memcache,gunzip和ssi的Nginx不能一起工作

我正在尝试在Memcached中保存packed(gzip)html并在nginx中使用:

  1. memcached模块加载来自memcached的html
  2. 如果打包,请通过nginx gunzip模块解压缩
  3. ssi模块处理ssi插入
  4. 将结果返回给用户

大多数情况下,配置工作,除了ssi步骤:

  location / {
    ssi on;
    set $memcached_key "$uri?$args";
    memcached_pass memcached.up;
    memcached_gzip_flag 2; #  net.spy.memcached use second byte for compression flag
    default_type text/html;
    charset utf-8;
    gunzip on;
    proxy_set_header Accept-Encoding "gzip";
    error_page  404 405 400 500 502 503 504 = @fallback;
  } 
Run Code Online (Sandbox Code Playgroud)

看起来,nginx在通过gunzip模块解压之前进行ssi处理.

在结果HTML中,我看到未解决的ssi指令:

<!--# include virtual="/remote/body?argument=value" -->
Run Code Online (Sandbox Code Playgroud)

nginx日志中没有错误.

尝试过ssi_types* - 没效果

知道怎么解决吗?

nginx 1.10.3(Ubuntu)

UPDATE

已经尝试了一个上游.相同的结果=(

在日志中,我看到,ssi过滤器在上游请求后应用,但没有检测到包含.

upstream memcached {
  server localhost:11211;
  keepalive 100;
}

upstream unmemcached {
  server …
Run Code Online (Sandbox Code Playgroud)

memcached nginx ssi

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

Grails update 2.3.11-> 2.4.3 ClassNotFoundException:org.hibernate.cache.access.AccessType

grails更新后我得到以下异常:

2014-10-28 17:12:27,651 [localhost-startStop-1] ERROR context.GrailsContextLoaderListener  - Error initializing the application: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/cache/access/AccessType
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean …
Run Code Online (Sandbox Code Playgroud)

grails hibernate grails-orm

3
推荐指数
1
解决办法
1983
查看次数