我有部门和员工实体。 Employee表有三列:
在Employee表中的非null键插入中插入null值。我在更新期间收到NullPointerException
prop.put(key, value)
期间现有密钥的非空值:
java.lang.NullPointerException at java.util.Hashtable.put(Hashtable.java:514)at org.eclipse.persistence.indirection.IndirectMap.put(IndirectMap.java:543) 在 org.eclipse.persistence.internal.queries.MapContainerPolicy.addInto(MapContainerPolicy.java:131) 在 org.eclipse.persistence.internal.queries.MappedKeyMapContainerPolicy.addInto(MappedKeyMapContainerPolicy.java:196) 在 org.eclipse.persistence.queries.DataReadQuery.executeNonCursor(DataReadQuery.java:226) 在 org.eclipse.persistence.queries.DataReadQuery.executeDatabaseQuery(DataReadQuery.java:152) 在 org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:899) 在 org.eclipse.persistence.queries.DataReadQuery.execute(DataReadQuery.java:137) 在 org.eclipse.persistence.queries.DatabaseQuery.executeInUnitOfWork(DatabaseQuery.java:798) 在 org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2896) 在 org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1804) 在 org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1786) 在 org.eclipse.persistence.internal.indirection.QueryBasedValueHolder.instantiate(QueryBasedValueHolder.java:129) 在 org.eclipse.persistence.internal.indirection.QueryBasedValueHolder.instantiate(QueryBasedValueHolder.java:116) 在 org.eclipse.persistence.internal.indirection.DatabaseValueHolder.getValue(DatabaseValueHolder.java:89) 在 org.eclipse.persistence.internal.indirection.UnitOfWorkValueHolder.instantiateImpl(UnitOfWorkValueHolder.java:173) 在 org.eclipse.persistence.internal.indirection.UnitOfWorkValueHolder.instantiate(UnitOfWorkValueHolder.java:234) 在 org.eclipse.persistence.internal.indirection.DatabaseValueHolder.getValue(DatabaseValueHolder.java:89) 在 org.eclipse.persistence.indirection.IndirectMap.buildDelegate(IndirectMap.java:109) 在 org.eclipse.persistence.indirection.IndirectMap.getDelegate(IndirectMap.java:329) 在 org.eclipse.persistence.indirection.IndirectMap.put(IndirectMap.java:543)
EclipseLink版本为2.5.2
我有部门和员工实体,部门实体类与员工实体有以下关系:
@Entity
@Table(name = "DEPARTMENT" uniqueConstraints = {
@UniqueConstraint(columnNames = { "NAME" }) })
@NamedQueries( {
@NamedQuery(name = Department.findAll", query = "select d from Department d"),
@NamedQuery(name = Department.findByName", query = "select d from Department d WHERE d.name = :name")})
public class Department implements Serializable {
@ElementCollection
@MapKeyColumn( name = "KEY")
@Column( name = "VALUE")
@CollectionTable(name="DEPARTMENT_PROP", joinColumns = @joinColumn(name= "DEPARTMENT_ID))
private final Map<String, String> props = new HashMap();
public Map<String, String> getProperties() {
return properties;
}
答案 0 :(得分:0)
实体类的方法或持久性实例变量都不是
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div id="my-container-div">container</div>
<input type="checkbox" value="0" />
<input type="checkbox" value="1" />
<input type="checkbox" value="2" />
。从final
中删除了此修饰符,映射注释看起来很好。
请注意,在java版本7中,您不能放置空值,因为props
不允许它,正如您在异常日志中看到的那样,它是EclipseLink的map实现使用。请参阅this java oficial doc。