mirror of
https://github.com/querydsl/querydsl.git
synced 2026-06-21 21:14:12 +08:00
#114 fixed get method handling
This commit is contained in:
parent
6178dd75db
commit
4b4e0d28a0
@ -99,9 +99,9 @@ public final class TypeElementHandler {
|
||||
if (config.visitMethodProperties()){
|
||||
for (ExecutableElement method : ElementFilter.methodsIn(elements)) {
|
||||
String name = method.getSimpleName().toString();
|
||||
if (name.startsWith("get") && method.getParameters().isEmpty()) {
|
||||
if (name.startsWith("get") && name.length() > 3 && method.getParameters().isEmpty()) {
|
||||
name = BeanUtils.uncapitalize(name.substring(3));
|
||||
} else if (name.startsWith("is") && method.getParameters().isEmpty()) {
|
||||
} else if (name.startsWith("is") && name.length() > 2 && method.getParameters().isEmpty()) {
|
||||
name = BeanUtils.uncapitalize(name.substring(2));
|
||||
} else {
|
||||
continue;
|
||||
|
||||
@ -31,6 +31,7 @@ import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.PrimaryKeyJoinColumn;
|
||||
import javax.persistence.Transient;
|
||||
import javax.persistence.Version;
|
||||
|
||||
import com.mysema.query.annotations.QueryTransient;
|
||||
@ -64,7 +65,7 @@ public class JPAConfiguration extends DefaultConfiguration {
|
||||
protected List<Class<? extends Annotation>> getAnnotations() {
|
||||
return Arrays.asList(Column.class, Embedded.class, EmbeddedId.class, GeneratedValue.class,
|
||||
Id.class, Version.class, JoinColumn.class, ManyToOne.class, OneToMany.class,
|
||||
PrimaryKeyJoinColumn.class, QueryType.class, QueryTransient.class);
|
||||
PrimaryKeyJoinColumn.class, QueryType.class, QueryTransient.class, Transient.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -0,0 +1,54 @@
|
||||
package com.mysema.query.domain;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import javax.persistence.Embeddable;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
@Embeddable
|
||||
@Deprecated
|
||||
public class FileAttachment {
|
||||
|
||||
@Transient
|
||||
Object model;
|
||||
@Transient
|
||||
String name;
|
||||
@Transient
|
||||
File f;
|
||||
public String filename;
|
||||
|
||||
public FileAttachment() {
|
||||
}
|
||||
|
||||
FileAttachment(Object model, String name) {
|
||||
this.model = model;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public File get() {
|
||||
return f;
|
||||
}
|
||||
|
||||
public void set(File file) {
|
||||
f = file;
|
||||
}
|
||||
|
||||
public boolean isSet() {
|
||||
return f != null || get() != null;
|
||||
}
|
||||
|
||||
public static File getStore() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean exists() {
|
||||
return isSet();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public long length() {
|
||||
return get().length();
|
||||
}
|
||||
|
||||
}
|
||||
@ -289,13 +289,15 @@ public class GenericExporter {
|
||||
// getters
|
||||
if (handleMethods) {
|
||||
for (Method method : cl.getDeclaredMethods()) {
|
||||
String name = method.getName();
|
||||
if (method.getParameterTypes().length == 0
|
||||
&& (method.getName().startsWith("get") || method.getName().startsWith("is"))) {
|
||||
&& ((name.startsWith("get") && name.length() > 3)
|
||||
|| (name.startsWith("is") && name.length() > 2))) {
|
||||
String propertyName;
|
||||
if (method.getName().startsWith("get")) {
|
||||
propertyName = BeanUtils.uncapitalize(method.getName().substring(3));
|
||||
if (name.startsWith("get")) {
|
||||
propertyName = BeanUtils.uncapitalize(name.substring(3));
|
||||
} else {
|
||||
propertyName = BeanUtils.uncapitalize(method.getName().substring(2));
|
||||
propertyName = BeanUtils.uncapitalize(name.substring(2));
|
||||
}
|
||||
if (handled.contains(propertyName)) {
|
||||
continue;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user