or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

configuration.mdcore-processing.mdframework-processors.mdindex.mdprocessing-options.md

framework-processors.mddocs/

0

# Framework-Specific Processors

1

2

Specialized annotation processors for different persistence frameworks, each handling framework-specific annotations and conventions while extending the core Querydsl processing capabilities.

3

4

## Capabilities

5

6

### JPA Annotation Processor

7

8

Processes JPA (Java Persistence API) annotations to generate type-safe query classes for JPA entities.

9

10

```java { .api }

11

/**

12

* Annotation processor for JPA entities

13

* Handles @Entity, @MappedSuperclass, @Embeddable, @Embedded, @Transient

14

*/

15

@SupportedAnnotationTypes({"com.mysema.query.annotations.*","javax.persistence.*"})

16

public class JPAAnnotationProcessor extends AbstractQuerydslProcessor {

17

18

/**

19

* Creates JPA-specific configuration

20

* @param roundEnv Processing environment

21

* @return JPAConfiguration with JPA annotation mappings

22

*/

23

@Override

24

protected Configuration createConfiguration(RoundEnvironment roundEnv);

25

}

26

27

/**

28

* JPA-specific configuration extending DefaultConfiguration

29

*/

30

public class JPAConfiguration extends DefaultConfiguration {

31

public JPAConfiguration(RoundEnvironment roundEnv, Map<String,String> options,

32

Class<? extends Annotation> entity,

33

Class<? extends Annotation> superType,

34

Class<? extends Annotation> embeddable,

35

Class<? extends Annotation> embedded,

36

Class<? extends Annotation> skip);

37

}

38

```

39

40

**Supported JPA Annotations:**

41

- `@Entity`: JPA entity classes → generates Q-classes

42

- `@MappedSuperclass`: JPA mapped superclasses → generates supertype Q-classes

43

- `@Embeddable`: JPA embeddable classes → generates embeddable Q-classes

44

- `@Embedded`: JPA embedded properties → processed as embedded types

45

- `@Transient`: JPA transient properties → excluded from Q-classes

46

47

**Usage Example:**

48

49

```java

50

import javax.persistence.*;

51

52

@Entity

53

@Table(name = "users")

54

public class User {

55

@Id

56

@GeneratedValue(strategy = GenerationType.IDENTITY)

57

private Long id;

58

59

@Column(name = "username", nullable = false)

60

private String username;

61

62

@Embedded

63

private Address address;

64

65

@Transient // Excluded from QUser

66

private String temporaryData;

67

}

68

69

@Embeddable

70

public class Address {

71

private String street;

72

private String city;

73

private String zipCode;

74

}

75

76

// Generates:

77

// - QUser.java with id, username, and address properties

78

// - QAddress.java for the embeddable type

79

```

80

81

### Hibernate Annotation Processor

82

83

Extends JPA processing with Hibernate-specific annotations and features.

84

85

```java { .api }

86

/**

87

* Hibernate annotation processor extending JPA support

88

* Handles JPA annotations plus Hibernate-specific annotations

89

*/

90

@SupportedAnnotationTypes({"com.mysema.query.annotations.*","javax.persistence.*", "org.hibernate.annotations.*"})

91

public class HibernateAnnotationProcessor extends JPAAnnotationProcessor {

92

93

/**

94

* Creates Hibernate-specific configuration with additional Hibernate support

95

* @param roundEnv Processing environment

96

* @return HibernateConfiguration with Hibernate annotation support

97

* @throws ClassNotFoundException if Hibernate classes not found

98

*/

99

@Override

100

protected Configuration createConfiguration(RoundEnvironment roundEnv) throws ClassNotFoundException;

101

}

102

103

/**

104

* Hibernate-specific configuration

105

*/

106

public class HibernateConfiguration extends JPAConfiguration {

107

public HibernateConfiguration(RoundEnvironment roundEnv, Map<String,String> options, ...);

108

}

109

```

110

111

**Additional Hibernate Support:**

112

- Hibernate-specific annotations in `org.hibernate.annotations.*` package

113

- Enhanced type mappings for Hibernate custom types

114

- Support for Hibernate-specific naming strategies

115

116

### JDO Annotation Processor

117

118

Processes JDO (Java Data Objects) annotations for generating query classes from JDO persistent classes.

119

120

```java { .api }

121

/**

122

* Annotation processor for JDO entities

123

* Handles @PersistenceCapable, @EmbeddedOnly, @NotPersistent

124

*/

125

@SupportedAnnotationTypes({"com.mysema.query.annotations.*","javax.jdo.annotations.*"})

126

public class JDOAnnotationProcessor extends AbstractQuerydslProcessor {

127

128

/**

129

* Creates JDO-specific configuration

130

* @param roundEnv Processing environment

131

* @return JDOConfiguration with JDO annotation mappings

132

*/

133

@Override

134

protected Configuration createConfiguration(RoundEnvironment roundEnv);

135

}

136

137

/**

138

* JDO-specific configuration

139

*/

140

public class JDOConfiguration extends DefaultConfiguration {

141

public JDOConfiguration(RoundEnvironment roundEnv, Map<String,String> options,

142

Class<? extends Annotation> entities,

143

Class<? extends Annotation> entity,

144

Class<? extends Annotation> superType,

145

Class<? extends Annotation> embeddable,

146

Class<? extends Annotation> embedded,

147

Class<? extends Annotation> skip);

148

}

149

```

150

151

**Supported JDO Annotations:**

152

- `@PersistenceCapable`: JDO persistent classes → generates Q-classes

153

- `@EmbeddedOnly`: JDO embeddable classes → generates embeddable Q-classes

154

- `@NotPersistent`: JDO non-persistent fields → excluded from Q-classes

155

- `@QueryEntities`: Package-level entity listing (Querydsl annotation)

156

- `@QuerySupertype`: Querydsl supertype annotation

157

- `@QueryEmbedded`: Querydsl embedded annotation

158

159

**Usage Example:**

160

161

```java

162

import javax.jdo.annotations.*;

163

import com.mysema.query.annotations.QueryEmbedded;

164

165

@PersistenceCapable

166

public class Customer {

167

@PrimaryKey

168

@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)

169

private Long customerId;

170

171

@Persistent

172

private String customerName;

173

174

@QueryEmbedded

175

@Persistent(embedded = "true")

176

private ContactInfo contact;

177

178

@NotPersistent // Excluded from QCustomer

179

private String cachedData;

180

}

181

```

182

183

### Morphia Annotation Processor

184

185

Processes MongoDB Morphia annotations for NoSQL document-based entities.

186

187

```java { .api }

188

/**

189

* Annotation processor for MongoDB Morphia entities

190

* Handles @Entity, @Embedded, @Transient from Morphia framework

191

*/

192

@SupportedAnnotationTypes({"com.mysema.query.annotations.*","org.mongodb.morphia.annotations.*"})

193

public class MorphiaAnnotationProcessor extends AbstractQuerydslProcessor {

194

195

/**

196

* Creates Morphia-specific configuration with MongoDB support

197

* @param roundEnv Processing environment

198

* @return DefaultConfiguration with Morphia annotation mappings and custom types

199

*/

200

@Override

201

protected Configuration createConfiguration(RoundEnvironment roundEnv);

202

}

203

```

204

205

**Supported Morphia Annotations:**

206

- `@org.mongodb.morphia.annotations.Entity`: MongoDB entities → generates Q-classes

207

- `@org.mongodb.morphia.annotations.Embedded`: Embedded documents → embeddable Q-classes

208

- `@org.mongodb.morphia.annotations.Transient`: Transient fields → excluded from Q-classes

209

- `@QueryEntities`: Package-level entity listing (Querydsl annotation)

210

- `@QuerySupertype`: Querydsl supertype annotation

211

212

**MongoDB-Specific Features:**

213

- Custom type mapping for `Double[]` arrays to spatial `Point` types

214

- Support for MongoDB document structure and embedded documents

215

- NoSQL-appropriate query generation patterns

216

217

**Usage Example:**

218

219

```java

220

import org.mongodb.morphia.annotations.*;

221

import com.mysema.query.annotations.QuerySupertype;

222

223

@Entity("products")

224

public class Product {

225

@Id

226

private ObjectId id;

227

228

private String name;

229

private Double price;

230

231

@Embedded

232

private ProductDetails details;

233

234

@Transient // Excluded from QProduct

235

private String sessionData;

236

}

237

238

@Entity

239

@QuerySupertype

240

public abstract class BaseEntity {

241

@Id

242

protected ObjectId id;

243

protected Date created;

244

protected Date modified;

245

}

246

```

247

248

### Spring Roo Annotation Processor

249

250

Processes Spring Roo annotations for Active Record pattern entities.

251

252

```java { .api }

253

/**

254

* Annotation processor for Spring Roo entities

255

* Handles @RooJpaEntity, @RooJpaActiveRecord plus standard JPA annotations

256

*/

257

@SupportedAnnotationTypes({"com.mysema.query.annotations.*","javax.persistence.*","org.springframework.roo.addon.jpa.entity.*"})

258

public class RooAnnotationProcessor extends AbstractQuerydslProcessor {

259

260

/**

261

* Creates Roo-specific configuration supporting both Roo and JPA annotations

262

* @param roundEnv Processing environment

263

* @return JPAConfiguration with alternative entity annotation for Active Record

264

*/

265

@Override

266

protected Configuration createConfiguration(RoundEnvironment roundEnv);

267

}

268

```

269

270

**Supported Roo Annotations:**

271

- `@RooJpaEntity`: Roo JPA entities → generates Q-classes

272

- `@RooJpaActiveRecord`: Roo Active Record entities → generates Q-classes (alternative)

273

- Standard JPA annotations: `@MappedSuperclass`, `@Embeddable`, `@Embedded`, `@Transient`

274

275

**Roo Integration Features:**

276

- Dual entity annotation support (primary: `@RooJpaEntity`, alternative: `@RooJpaActiveRecord`)

277

- Integration with Roo's Active Record pattern

278

- Compatible with Roo's code generation and AspectJ weaving

279

280

**Usage Example:**

281

282

```java

283

import org.springframework.roo.addon.jpa.entity.RooJpaEntity;

284

import org.springframework.roo.addon.jpa.activerecord.RooJpaActiveRecord;

285

import javax.persistence.*;

286

287

@RooJpaEntity

288

@Entity

289

public class Book {

290

@Id

291

@GeneratedValue(strategy = GenerationType.AUTO)

292

private Long id;

293

294

private String title;

295

private String author;

296

private Integer pages;

297

}

298

299

@RooJpaActiveRecord // Alternative entity annotation

300

@Entity

301

public class Author {

302

@Id

303

@GeneratedValue

304

private Long id;

305

306

private String name;

307

private String biography;

308

}

309

```

310

311

## Service Registration

312

313

All processors are automatically registered via the Java Service Provider Interface using META-INF/services files:

314

315

```

316

META-INF/services/javax.annotation.processing.Processor

317

```

318

319

**Registration Files:**

320

- `general/`: `com.mysema.query.apt.QuerydslAnnotationProcessor`

321

- `jpa/`: `com.mysema.query.apt.jpa.JPAAnnotationProcessor`

322

- `hibernate/`: `com.mysema.query.apt.hibernate.HibernateAnnotationProcessor`

323

- `jdo/`: `com.mysema.query.apt.jdo.JDOAnnotationProcessor`

324

- `morphia/`: `com.mysema.query.apt.morphia.MorphiaAnnotationProcessor`

325

- `roo/`: `com.mysema.query.apt.roo.RooAnnotationProcessor`

326

327

This enables automatic processor discovery by the Java compiler and build tools without explicit configuration.