Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Controlling column order when creating tables with ddl-generation
Controlling column order when creating tables with ddl-generation [message #388115] Mon, 25 May 2009 15:33 Go to next message
Dean Schulze is currently offline Dean SchulzeFriend
Messages: 24
Registered: July 2009
Junior Member
I'm using EclipseLink with the "eclipselink.ddl-generation" property set
to "create-tables". The order of the columns in the created tables seems
random. I want the columns in a particular order - the order in which the
fields appear in the Entity class definition.

My database is PostgresQL.

Is there a way to tell EclipseLink to create the columns in the order in
the Entity class definition or some other way to specify column order?

Thanks.
Re: Controlling column order when creating tables with ddl-generation [message #388423 is a reply to message #388115] Mon, 25 May 2009 18:01 Go to previous messageGo to next message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

There is a method on ClassDescriptor in EclipseLink,
setShouldOrderMappings(), if you set this to false, you might get the
order you are looking for.

Otherwise, you could use your own script to create your tables, the order
the columns are declared in should not really matter.

---
James
http://www.nabble.com/EclipseLink---Users-f26658.html


James : Wiki : Book : Blog : Twitter
Re: Controlling column order when creating tables with ddl-generation [message #735928 is a reply to message #388423] Thu, 13 October 2011 06:50 Go to previous messageGo to next message
Boyd Pang is currently offline Boyd PangFriend
Messages: 12
Registered: June 2011
Junior Member
Hello James,

In my application,I define an entity class and a class implements DescriptorCustomizer,


@Entity
@Table(name = "adapter")
@Customizer(OrderCustomizer.class)
public class AdapterRecord implements Comparable<AdapterRecord>, Serializable
{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private int id;

	private String name;
	
	private int serialNum;
	
	private boolean isRunnig;
	
	private String serverIp;

	@Temporal(TemporalType.TIMESTAMP)
	private Date startTime;
	
	private int test;
	private int test1;
	private int ptest;
	
	private String pIp;
	private String sIp;
	
	private int aTest;

......
}


public class OrderCustomizer implements DescriptorCustomizer
{
	@Override
	public void customize(ClassDescriptor descriptor)
	{
		descriptor.setShouldOrderMappings(false);

	}


}



I want the columns in a particular order - the order in which the
fields appear in the Entity class definition.

But when I run the application ,I got columns order :

index.php/fa/4248/0/

starttime,
id,
atest,
test1,
test,
name,
serverip,
isrunning,
serialnum,
pIp,
ptest,
sip

Could you give me some help ? Thanks a lot.

Boyd
  • Attachment: columns.JPG
    (Size: 51.96KB, Downloaded 872 times)

[Updated on: Thu, 13 October 2011 06:56]

Report message to a moderator

Re: Controlling column order when creating tables with ddl-generation [message #741962 is a reply to message #735928] Thu, 20 October 2011 03:49 Go to previous messageGo to next message
Boyd Pang is currently offline Boyd PangFriend
Messages: 12
Registered: June 2011
Junior Member
Can someone help me?

Thanks for any suggestion.

Boyd.

[Updated on: Thu, 20 October 2011 03:50]

Report message to a moderator

Re: Controlling column order when creating tables with ddl-generation [message #741966 is a reply to message #735928] Thu, 20 October 2011 03:49 Go to previous message
Boyd Pang is currently offline Boyd PangFriend
Messages: 12
Registered: June 2011
Junior Member
Can someone help me?

Thanks for any suggesion.

Boyd.
Previous Topic:what maven artefact for (DynamicJaxbContext with xsd) ...jaxb.dynamic.metadata.SchemaMetadata
Next Topic:Cached Ordered Lists have null inserted during 2nd update
Goto Forum:
  


Current Time: Fri Apr 19 15:01:51 GMT 2024

Powered by FUDForum. Page generated in 0.01621 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top