APT processor general issue #114

Closed
7uc0 opened this Issue Mar 9, 2012 · 3 comments

Comments

Projects
None yet
2 participants
@7uc0

7uc0 commented Mar 9, 2012

Hi there,

Following @embeddable element leads to missing identifier

Source


@Embeddable
public class FileAttachment {

    @Transient
    Object model;

    @Transient
    String name;

    @Transient
    File f;

    public String filename;  
}

generated QFileAttachement :



package play.db.jpa;

import static com.mysema.query.types.PathMetadataFactory.*;

import com.mysema.query.types.*;
import com.mysema.query.types.path.*;

import javax.annotation.Generated;


/**
 * QFileAttachment is a Querydsl query type for FileAttachment
 */
@Generated("com.mysema.query.codegen.EmbeddableSerializer")
public class QFileAttachment extends BeanPath<FileAttachment> {

    private static final long serialVersionUID = -1147555192;

    public static final QFileAttachment fileAttachment = new QFileAttachment("fileAttachment");

    public final ComparablePath<java.io.File>  = createComparable("", java.io.File.class);

    public final StringPath filename = createString("filename");

    public final BooleanPath set = createBoolean("set");

    public QFileAttachment(String variable) {
        super(FileAttachment.class, forVariable(variable));
    }

    public QFileAttachment(Path<? extends FileAttachment> entity) {
        super(entity.getType(), entity.getMetadata());
    }

    public QFileAttachment(PathMetadata<?> metadata) {
        super(FileAttachment.class, metadata);
    }

}

and lead to following error at compilation time :

<identifier> expected 

public final ComparablePath<java.io.File>  = createComparable("", java.io.File.class);

@7uc0

This comment has been minimized.

Show comment
Hide comment
@7uc0

7uc0 Mar 9, 2012

Affects 2.3.2 version

7uc0 commented Mar 9, 2012

Affects 2.3.2 version

@7uc0

This comment has been minimized.

Show comment
Hide comment
@7uc0

7uc0 Mar 9, 2012

package play.db.jpa;

import java.io.File;
import javax.persistence.Embeddable;
import javax.persistence.Transient;
import play.Play;
import play.libs.Files;

/**
 * Please use play.db.jpa.Blob now
 */
@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() {
        if (f != null) {
            return f;
        }
        File file = new File(getStore(), model.getClass().getName() + "." + name + "_" + ((Model) model)._key());
        if (file.exists()) {
            f = file;
        }
        return f;
    }

    public void set(File file) {
        f = file;
    }

    void save() {
        if (f != null) {
            File to = new File(getStore(), model.getClass().getName() + "." + name + "_" + ((Model) model)._key());
            Files.copy(f, to);
        }
    }

    void delete() {
        File to = new File(getStore(), model.getClass().getName() + "." + name + "_" + ((Model) model)._key());
        if (to.exists()) {
            to.delete();
        }
        name = null;
    }

    public boolean isSet() {
        return f != null || get() != null;
    }

    public static File getStore() {
        String name = Play.configuration.getProperty("attachments.path", "attachments");
        File store = null;
        if (new File(name).isAbsolute()) {
            store = new File(name);
        } else {
            store = Play.getFile(name);
        }
        if (!store.exists()) {
            store.mkdirs();
        }
        return store;
    }

    // Make it compatible with new Blob

    @Deprecated
    public boolean exists() {
        return isSet();
    }

    @Deprecated
    public long length() {
        return get().length();
    }

}

7uc0 commented Mar 9, 2012

package play.db.jpa;

import java.io.File;
import javax.persistence.Embeddable;
import javax.persistence.Transient;
import play.Play;
import play.libs.Files;

/**
 * Please use play.db.jpa.Blob now
 */
@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() {
        if (f != null) {
            return f;
        }
        File file = new File(getStore(), model.getClass().getName() + "." + name + "_" + ((Model) model)._key());
        if (file.exists()) {
            f = file;
        }
        return f;
    }

    public void set(File file) {
        f = file;
    }

    void save() {
        if (f != null) {
            File to = new File(getStore(), model.getClass().getName() + "." + name + "_" + ((Model) model)._key());
            Files.copy(f, to);
        }
    }

    void delete() {
        File to = new File(getStore(), model.getClass().getName() + "." + name + "_" + ((Model) model)._key());
        if (to.exists()) {
            to.delete();
        }
        name = null;
    }

    public boolean isSet() {
        return f != null || get() != null;
    }

    public static File getStore() {
        String name = Play.configuration.getProperty("attachments.path", "attachments");
        File store = null;
        if (new File(name).isAbsolute()) {
            store = new File(name);
        } else {
            store = Play.getFile(name);
        }
        if (!store.exists()) {
            store.mkdirs();
        }
        return store;
    }

    // Make it compatible with new Blob

    @Deprecated
    public boolean exists() {
        return isSet();
    }

    @Deprecated
    public long length() {
        return get().length();
    }

}

timowest added a commit that referenced this issue Mar 9, 2012

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Mar 11, 2012

Member

released in 2.3.3

Member

timowest commented Mar 11, 2012

released in 2.3.3

@timowest timowest closed this Mar 11, 2012

@timowest timowest reopened this Mar 11, 2012

@timowest timowest closed this Mar 11, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment