作用是json序列化时将java bean中的一些属性忽略掉,序列化和反序列化都受影响。

如下:

package com.hzboy.orm;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient; import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.annotate.JsonManagedReference; /**
* 系统用户实体类
* @author tinner
*
*/
@Entity(name = "com.hzboy.orm.User")
@Table(name = "sys_user")
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
public class User extends BaseEntity { /**
*
*/
private static final long serialVersionUID = -1343842065506227012L; public User() { } public User(Integer id) {
this.id = id;
} // 登录名
private String loginName;
// 密码123456-b594510740d2ac4261c1b2fe87850d08
private String pswd;
// 姓名
private String nickName;
// 性别
private Short sex;
// 年龄段
private String ageStage;
// 是否系统管理员
private boolean systemAdmin;
//联系电话
private String tel;
//Email
private String email;
//是否工程师
private Boolean isEnginner;
//是否前端客户 是则显示前台html,但同时保留后台相关模块
private Boolean isFrontUser;
//相关部门
private Department department;
//相关部门前台描述
private String departmentName;
private Integer departmentId;
//用户编号
private String userCode;
//附加用于导入
private String idCode;
//附加的部门信息 用于计算
private String departmentCode;
@Column(name = "login_name")
public String getLoginName() {
return loginName;
} public void setLoginName(String loginName) {
this.loginName = loginName;
} @Column(name = "pswd")
public String getPswd() {
return pswd;
} public void setPswd(String pswd) {
this.pswd = pswd;
} @Column(name = "nick_name")
public String getNickName() {
return nickName;
} public void setNickName(String nickName) {
this.nickName = nickName;
} @Column(name = "sex")
public Short getSex() {
return sex;
} public void setSex(Short sex) {
this.sex = sex;
} @Column(name = "age_stage")
public String getAgeStage() {
return ageStage;
} public void setAgeStage(String ageStage) {
this.ageStage = ageStage;
} @Column(name = "system_admin")
public boolean isSystemAdmin() {
return systemAdmin;
} public void setSystemAdmin(boolean systemAdmin) {
this.systemAdmin = systemAdmin;
} private List<Role> roles; @ManyToMany(fetch = FetchType.LAZY, cascade = (CascadeType.REMOVE))
@JoinTable(name = "sys_user_role", joinColumns = { @JoinColumn(name = "user_id") }, inverseJoinColumns = { @JoinColumn(name = "role_id") })
public List<Role> getRoles() {
return roles;
} public void setRoles(List<Role> roles) {
this.roles = roles;
} private Integer[] roleIds; @Transient
public Integer[] getRoleIds() {
return roleIds;
} public void setRoleIds(Integer[] roleIds) {
this.roleIds = roleIds;
}
@Column(name="email")
public String getEmail() {
return email;
} public void setEmail(String email) {
this.email = email;
}
@Column(name="is_enginner")
public Boolean getIsEnginner() {
return isEnginner;
} public void setIsEnginner(Boolean isEnginner) {
this.isEnginner = isEnginner;
}
@Column(name="is_front_user")
public Boolean getIsFrontUser() {
return isFrontUser;
} public void setIsFrontUser(Boolean isFrontUser) {
this.isFrontUser = isFrontUser;
} public String getTel() {
return tel;
} public void setTel(String tel) {
this.tel = tel;
}
@JsonIgnore
@ManyToOne(cascade = { CascadeType.PERSIST, CascadeType.MERGE }, fetch = FetchType.LAZY)
@JoinColumn(name="department_id")
public Department getDepartment() {
return department;
}
@JsonManagedReference
public void setDepartment(Department department) {
this.department = department;
} @Transient
public String getDepartmentName() {
return departmentName;
} public void setDepartmentName(String departmentName) {
this.departmentName = departmentName;
} @Transient
public Integer getDepartmentId() {
return departmentId;
} public void setDepartmentId(Integer departmentId) {
this.departmentId = departmentId;
}
@Column(name="user_code")
public String getUserCode() {
return userCode;
} public void setUserCode(String userCode) {
this.userCode = userCode;
}
@Column(name="id_from_import")
public String getIdCode() {
return idCode;
} public void setIdCode(String idCode) {
this.idCode = idCode;
}
public String getDepartmentCode() {
return departmentCode;
} public void setDepartmentCode(String departmentCode) {
this.departmentCode = departmentCode;
}
}

上个实体User中的  department属性就在getDepartment属性上加了  @JsonIgnore,这个时候从后台推数据到前台的时候,就会把department这个引用属性给忽略掉。

@jsonignore的作用的更多相关文章

  1. Hibernate JPA中@Transient、@JsonIgnoreProperties、@JsonIgnore、@JsonFormat、@JsonSerialize等注解解释

    @jsonignore的作用作用是json序列化时将java bean中的一些属性忽略掉,序列化和反序列化都受影响. http://www.cnblogs.com/toSeeMyDream/p/443 ...

  2. springboot主要注解及其作用

    1.注解(annotations)列表 @SpringBootApplication:包含了@ComponentScan.@Configuration和@EnableAutoConfiguration ...

  3. 第一章 JacksonUtil 序列化与反序列化属性总结

    1.json-lib与Jackson 关于json-lib与Jackson对比总结如下: 1).性能方面,Jackson的处理能力高出Json-lib10倍左右. 2).json-lib已经停止更新, ...

  4. Spring Boot 注解详解

    一.注解(annotations)列表 @SpringBootApplication:包含了@ComponentScan.@Configuration和@EnableAutoConfiguration ...

  5. 三。Hibernate 注解形式

    Hibernate支持JPA注解的jar包 JPA全称: Java Persistence API JPA和Hibernate之间的关系,可以简单的理解为JPA是标准接口,Hibernate是实现. ...

  6. SpringBoot注解大全 转

    2019年3月17日22:30:10 一.注解(annotations)列表 @SpringBootApplication:包含了@ComponentScan.@Configuration和@Enab ...

  7. springBoot系列-->springBoot注解大全

    一.注解(annotations)列表 @SpringBootApplication:包含了@ComponentScan.@Configuration和@EnableAutoConfiguration ...

  8. SpringBoot注解大全(转)

    原文链接:[springBoot系列]--springBoot注解大全 一.注解(annotations)列表 @SpringBootApplication:包含了@ComponentScan.@Co ...

  9. [springBoot系列]--springBoot注解大全[转]

    一.注解(annotations)列表 @SpringBootApplication:包含了@ComponentScan.@Configuration和@EnableAutoConfiguration ...

随机推荐

  1. Redis杂记

    参考资料: Redis 教程 | 菜鸟教程 : http://www.runoob.com/redis/redis-tutorial.html Redis快速入门 :http://www.yiibai ...

  2. TLS学习总结

    我们有知道 Immunity Debugger,OD 调试器,在调试程序时会设断在OEP(修改第一个字节0xcc).我在想,使用什么编程技术,代码可以在OEP前被执行.在网上找了些资料,在论坛上看到许 ...

  3. C# excel操作

    开源的Excel操作项目: http://www.cnblogs.com/lwme/archive/2011/11/27/2265323.html 添加引用:Microsoft Excel 11.0 ...

  4. java 静态构造函数

    在java中貌似是没有静态构造函数的. 不过用下面的方式同样可以实现效果. static { }//end 这是静态代码块

  5. poj 3621(最优比率环)

    题目链接:http://poj.org/problem?id=3621 思路:之前做过最小比率生成树,也是属于0/1整数划分问题,这次碰到这道最优比率环,很是熟悉,可惜精度没控制好,要不就是wa,要不 ...

  6. JS事件驱动机制

    还记得当初学JAVA-GUI编程时学习过事件监听机制,此时再学习JavaScript中的事件驱动机制,不免简单.当初学习时也是画过原理图,所以从原理图开始吧! js是采用事件驱动(event-driv ...

  7. Java IO(一)

       字节流的两个基类: InputStream OutputStream 字符流的两个基类: Reader Writer Writer 先学习一下字符流的特点. 既然IO流是用于操作数据的,那么数据 ...

  8. Redis 集群实现

    Nosql,作为程序员在当下不了解点儿,还真不行,出去聊起来别人就会说你土.那么就聊聊其中一个比较火的redis.redis单机版没得说,但是一直没有集群版,有也是山寨的.前段时间对redis的实现进 ...

  9. hdu 4762 Cut the Cake (大数乘法)

    猜公式: ans=n/m^(n-1) #include<stdio.h> #include<string.h> struct BigNum { ]; int len; }; i ...

  10. Qt之QSpacerItem(控件之间的间距不尽相同,可以借助QSpacerItem来设置,并且还可以对QSpacerItem设置QSizePolicy)

    http://blog.csdn.net/u011012932/article/details/51614868